I have a gridview, with first column as checkbox. I also have a checkbox "Select All", which select/de-selects all checkboxes in the first column of Grid.
But when after selecting-deselecting the grid checkbox through "Select All" checkbox, I selects few checkboxes in gridview and see the result of the checked checkbox, I see the following error
Conversion from string "" to type 'Boolean' is not valid.
Here is a code that I am using
Private Sub chSelectAll_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles chSelectAll.CheckedChanged
Try
For i = 0 To dgMain.RowCount - 1
If chSelectAll.Checked = True Then
dgMain.Rows(i).Cells(0).Value = "True"
' dgMain.CommitEdit(DataGridViewDataErrorContexts.Commit)
Else
dgMain.Rows(i).Cells(0).Value = "False"
' dgMain.CommitEdit(DataGridViewDataErrorContexts.Commit)
End If
Next
Catch ex As Exception
Debug.Print("Error occurred: " & ex.Message.ToString)
End Try
End Sub
Private Sub dgMain_CellContentClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles dgMain.CellContentClick
Try
If e.ColumnIndex = 0 Then
If dgMain.Rows(e.RowIndex).Cells(e.ColumnIndex).Value = "False" Then
dgMain.Rows(e.RowIndex).Cells(e.ColumnIndex).Value = "True"
Else
dgMain.Rows(e.RowIndex).Cells(e.ColumnIndex).Value = "False"
End If
End If
Catch ex As Exception
Debug.Print("Error occurred: " & ex.Message.ToString)
End Try
End Sub
Private Sub cmdLoad_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles cmdEmail.Click
'
Try
For i = 0 To dgMain.RowCount - 1
If dgMain.Rows(i).Cells(0).Value = True Then '''''''Errors come on this line
If dgMain.Rows(i).Cells(7).Value <> "" Then
''''Something...
End If
End If
Next
Me.Close()
Catch ex As Exception
MessageBox.Show("Error occurred: " & ex.Message.ToString)
End Try
'
End Sub
Somebody Please help me at the earliest....