A
Atif Jalal
I have a datagrid with a checkbox as one of the column. When the
checkboxes are selected and a delete button at the bottom of the grid
is clicked, I want the selected row in grid to be deleted. I am having
trouble in determining the key of the selected record. I get the error
index out of range. The code is as follows in VB.net. Your help
appreciated.
For Each dgi In MySearchesGrid.Items
cb = CType(dgi.Cells(0).Controls(1), CheckBox)
If cb.Checked Then
'' Determine the key of the selected record ...
bookid = CType(MySearchesGrid.DataKeys(i), Integer)
<----- get an error at this point
' ... get a pointer to the corresponding dataset
record ...
dr = Me.dsMySearches.Tables(0).Rows(bookid)
' ... and delete it.
dr.Delete()
End If
i += 1
Next
checkboxes are selected and a delete button at the bottom of the grid
is clicked, I want the selected row in grid to be deleted. I am having
trouble in determining the key of the selected record. I get the error
index out of range. The code is as follows in VB.net. Your help
appreciated.
For Each dgi In MySearchesGrid.Items
cb = CType(dgi.Cells(0).Controls(1), CheckBox)
If cb.Checked Then
'' Determine the key of the selected record ...
bookid = CType(MySearchesGrid.DataKeys(i), Integer)
<----- get an error at this point
' ... get a pointer to the corresponding dataset
record ...
dr = Me.dsMySearches.Tables(0).Rows(bookid)
' ... and delete it.
dr.Delete()
End If
i += 1
Next