开发者

get value of Checkbox in datagrid

开发者 https://www.devze.com 2023-01-03 01:42 出处:网络
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.

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)
               开发者_如何学Python 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.


What if you try this?

If Not String.IsNullOrEmpty(dr.Cells(0).Value) Then
   'do stuff here
End If
0

精彩评论

暂无评论...
验证码 换一张
取 消