I am attempting to write some code to delete a row from a datagrid. My code is throwing the index out of range error right on the first line of code in my deletecommand event:
Dim strSubCatID As Int32 = dgSubCat.DataKeys(e.Item.ItemIndex)
Dim dr As DataRow
Dim i As Integer
For i = 0 To DAcmp.DsBudget.Tables("spSelSubCat").Rows.Count - 1
dr = DAcmp.DsBudget.Tables("spSubCat").Rows(i)
If dr(0) = strSubCatID Then
Exit For
End If
Next
dr.Delete()
DAcmp.daSubCat.Update(DAcmp.DsBudget, "spSelSubCat")
SetDS()
Any ideas?
Dim strSubCatID As Int32 = dgSubCat.DataKeys(e.Item.ItemIndex)
Dim dr As DataRow
Dim i As Integer
For i = 0 To DAcmp.DsBudget.Tables("spSelSubCat").Rows.Count - 1
dr = DAcmp.DsBudget.Tables("spSubCat").Rows(i)
If dr(0) = strSubCatID Then
Exit For
End If
Next
dr.Delete()
DAcmp.daSubCat.Update(DAcmp.DsBudget, "spSelSubCat")
SetDS()
Any ideas?