views:

98

answers:

1

I am working with windows application. I have a datagrid in vb.net. Its first column is a checkbox. I want to know which checkboxes are checked and which are not.
My code is :

         Dim dr As DataGridViewRow
            For i = 0 To gdStudInfo.RowCount - 1
                dr = gdStudInfo.Rows(i)
                att = dr.Cells(0).Value.ToString()
                If att.Equals("Present") Then
                    qry = "insert into Stu_Att_Detail values(" & id & "," & gdStudInfo.Rows(i).Cells(1).Value.ToString() & ",'" & dr.Cells(0).Value.ToString() & "')"
                    con.MyQuery(qry)
                End If
            Next  

I am getting correct values for all checked check box, but it gets error when the checkbox is not checked.

+2  A: 

What if you try this?

If Not String.IsNullOrEmpty(dr.Cells(0).Value) Then
   'do stuff here
End If
Antony Highsky
@Draak Yes, This was the problem that unchecked checkboxes where giving null value. But If I want that at the filling time all checkboxes should be by default checked then what should I do?
Himadri