datagrid column coding if else

Joined
Aug 8, 2011
Messages
20
Location
Batangas City, Philippines
Programming Experience
Beginner
i got a datagrid connected to sql...

my problem is i have two columns which is grade and evaluation

i need to do is..

if grade has a value of 1-3 print passed
and 4 above will print failed

--------------------a string will be printed in evaluation column

here is my sample code of mine.. which didnt work..

dim grade as datacolumn
dim evaluation as datacolumn

For i As Integer = 0 To Me.DataGridView.RowCount - 1
if DataGridView.item(Grade,i)​="" then
DataGridView.item(evaluati​on,i)="Unknown"
else
if DataGridView.item(Grade,i)​>4 then

DataGridView.item(evaluati​on,i)="Failed"
else

DataGridView.item(evaluati​on,i)="Passed"
End if
Enf if
Next​

 
First, please post each question once and once only. Your duplicate thread has been deleted. Second, please update your profile as you cannot possibly be targeting .NET 1.0 if you are using a DataGridView.

As for the question, this really shouldn't have anything to do with the grid. I'd suggest that you add an extra column to your DataTable and set its Expression property. That way the value in that column will be set automatically based on the value in the other column, also updating automatically if the other column changes. The appropriate expression would be:
VB.NET:
IIF(Grade >= 4, 'Failed', IIF(Grade IN (1, 2, 3), 'Passed', 'Unknown'))
 

Latest posts

Back
Top