get value of Checkbox in datagrid

Posted by Himadri on Stack Overflow See other posts from Stack Overflow or by Himadri
Published on 2010-06-12T18:12:44Z Indexed on 2010/06/12 21:23 UTC
Read the original article Hit count: 315

Filed under:
|
|

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.

© Stack Overflow or respective owner

Related posts about Windows

Related posts about vb.net