code to loop thru the checkboxes and read their status and do some operation

By Sakshi a

This code loops through the checkboxes in a datagridview control and reads their status and do one updation to a global object. This will be mostly used in grid based pages where we need to check status of some field and do some relative task based on that. Even you can reuse this login in all grid controls. Also it is properly encasulated into exception handling mechanism.

Private Sub btnUpdate_Click(ByVal  sender As System.Object, ByVal e As System.EventArgs ) Handles btnUpdate.Click


Dim j As Integer

If MsgBox("Are you Sure ?", MsgBoxStyle.YesNo + MsgBoxStyle.Critical, "Confirmation") = MsgBoxResult.Yes Then

For j = 0 To Me.dgdvConStatus.Rows.Count - 1

Dim ck As DataGridViewCheckBoxCell

Dim nrow1 As Integer = j

ck =

If ck.Value = True Then

Me.dgdvConStatus.Rows(j).Cells(1).Value(), "1")

ElseIf ck.Value = False Then

Me.dgdvConStatus.Rows(j).Cells(1).Value(), "0")

End If


"Content Status Updation done Successfully")

End If

Catch ex As Exception

" Error : " & ex.Message)

End Try

End Sub

code to loop thru the checkboxes and read their status and do some operation  (651 Views)