Datagrid validation error DBNull Casting ...

bluebell

New member
Joined
Jul 25, 2005
Messages
1
Programming Experience
10+
Hi!

I have a datagrid with 3 combo boxes that needs to be selected, the datagrid is populated with data from database. on an empty datagrid the validation for checking whether values have been selected works fine when pressing the Add button, The problem arises when user has selected all 3 combo boxes and in the second row does not select the first combo box, then I get Cast from DBNull Value to string is not valid. The problem is only with the first combo box, if first is selected n the others are left out validation works fine

If Len(Trim(dgrd.Item(i, 1).ToString)) <> 0 And Len(Trim(dgrd.Item(i, 3).ToString)) <> 0 And Len(Trim(dgrd.Item(i, 6).ToString)) <> 0 Then
-----

I have tried validating the datagrid cell first for dbnull value it does not work ...

does anyone know how to get around this DBNull ...

thanks in advance
 
Back
Top