I am trying to get my grid to update my supplier table but I keep getting an error.
Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: index
Protected Sub grdSuppliers_Competetitors_UpdateCommand(ByVal source As Object, ByVal e As Telerik.Web.UI.GridCommandEventArgs) Handles grdSuppliers_Competetitors.UpdateCommand
Dim oSup As New SupplierCompetitor
'Get the GridEditableItem of the RadGrid
Dim editedItem As GridEditableItem = TryCast(e.Item, GridEditableItem)
'Get the primary key value using the DataKeyValue.
Dim SupplierCompetitorID As String = editedItem.OwnerTableView.DataKeyValues(editedItem.ItemIndex)("SupplierCompetitorID").ToString()
'Access the textbox from the edit form template and store the values in string variables.
'Dim SupplierCompetitorID As String = (TryCast(editedItem("SupplierCompetitorID").Controls(0), TextBox)).Text
Dim supplierCompetitorName As String = (TryCast(editedItem("supplierCompetitorName").Controls(0), TextBox)).Text
Dim IsCompAs Boolean = (TryCast(editedItem("IsComp").Controls(0), CheckBox)).Checked
If (TryCast(editedItem("IsWard").Controls(0), CheckBox)).Checked Then
If oSup.IsCompExists Then
Me.Label1.Text = "Another supplier/competitor has already been defined as Ward."
Me.Label1.Visible = True
End If
ElseIf oSup.Exists(supplierCompetitorName) Then
Me.Label1.Text = "Supplier/Competitor entered already exists."
Me.Label1.Visible = True
Else
oSup.UpdateSupplierCompetitor(SupplierCompetitorID, supplierCompetitorName, IsComp)
End If
Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: index
Protected Sub grdSuppliers_Competetitors_UpdateCommand(ByVal source As Object, ByVal e As Telerik.Web.UI.GridCommandEventArgs) Handles grdSuppliers_Competetitors.UpdateCommand
Dim oSup As New SupplierCompetitor
'Get the GridEditableItem of the RadGrid
Dim editedItem As GridEditableItem = TryCast(e.Item, GridEditableItem)
'Get the primary key value using the DataKeyValue.
Dim SupplierCompetitorID As String = editedItem.OwnerTableView.DataKeyValues(editedItem.ItemIndex)("SupplierCompetitorID").ToString()
'Access the textbox from the edit form template and store the values in string variables.
'Dim SupplierCompetitorID As String = (TryCast(editedItem("SupplierCompetitorID").Controls(0), TextBox)).Text
Dim supplierCompetitorName As String = (TryCast(editedItem("supplierCompetitorName").Controls(0), TextBox)).Text
Dim IsCompAs Boolean = (TryCast(editedItem("IsComp").Controls(0), CheckBox)).Checked
If (TryCast(editedItem("IsWard").Controls(0), CheckBox)).Checked Then
If oSup.IsCompExists Then
Me.Label1.Text = "Another supplier/competitor has already been defined as Ward."
Me.Label1.Visible = True
End If
ElseIf oSup.Exists(supplierCompetitorName) Then
Me.Label1.Text = "Supplier/Competitor entered already exists."
Me.Label1.Visible = True
Else
oSup.UpdateSupplierCompetitor(SupplierCompetitorID, supplierCompetitorName, IsComp)
End If