Hi
I'm getting the following error for the code below it:
----------------------------------------------------------
Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: index
----------------------------------------------------------
Private Sub dGridTypes_UpdateCommand(ByVal source As System.Object, ByVal e As System.Web.UI.WebControls.DataGridCommandEventArgs) Handles dGridTypes.UpdateCommand
Dim txtCode As TextBox
Dim txtDescription As TextBox
'store textbox values into variables
txtCode = CType(e.Item.Cells(0).Controls(0), TextBox)
txtDescription = CType(e.Item.Cells(1).Controls(0), TextBox)
'Assign Parameters to SqlCommand
SqlComm_UpdateType.Parameters("@Code").Value = txtCode.Text
SqlComm_UpdateType.Parameters("@Description").Value = txtDescription.Text
SqlComm_UpdateType.Parameters("@TypeID").Value = dGridTypes.DataKeys(e.Item.ItemIndex)
'Execute SqlCommand
Me.SqlConnection1.Open()
SqlComm_UpdateType.ExecuteNonQuery()
'Deselect Row for editing
dGridTypes.EditItemIndex = -1
BindGrid()
Me.SqlConnection1.Close()
End Sub
Any help greatly appreciated.
I'm getting the following error for the code below it:
----------------------------------------------------------
Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: index
----------------------------------------------------------
Private Sub dGridTypes_UpdateCommand(ByVal source As System.Object, ByVal e As System.Web.UI.WebControls.DataGridCommandEventArgs) Handles dGridTypes.UpdateCommand
Dim txtCode As TextBox
Dim txtDescription As TextBox
'store textbox values into variables
txtCode = CType(e.Item.Cells(0).Controls(0), TextBox)
txtDescription = CType(e.Item.Cells(1).Controls(0), TextBox)
'Assign Parameters to SqlCommand
SqlComm_UpdateType.Parameters("@Code").Value = txtCode.Text
SqlComm_UpdateType.Parameters("@Description").Value = txtDescription.Text
SqlComm_UpdateType.Parameters("@TypeID").Value = dGridTypes.DataKeys(e.Item.ItemIndex)
'Execute SqlCommand
Me.SqlConnection1.Open()
SqlComm_UpdateType.ExecuteNonQuery()
'Deselect Row for editing
dGridTypes.EditItemIndex = -1
BindGrid()
Me.SqlConnection1.Close()
End Sub
Any help greatly appreciated.