i am trying to add a edit button where the data displayed in the textboxes from the selected record in the datagridview on vb gets update if i change any details when i press the edit button. problem is when i click the button it says 'There is no row at position 0' on the line............COMP4DataSet.Tables("StockControl").Rows(selecteditem).Item("Product Type") = txtProductType.Text
here is my code:
'edit button
Dim selecteditem As Integer
SelectedItem = grdStockControl.CurrentRow.Index
COMP4DataSet.Tables("Stock Control").Rows(selecteditem).Item("Product Type") = txtProductType.Text
COMP4DataSet.Tables("Stock Control").Rows(selecteditem).Item("Make") = txtMake.Text
COMP4DataSet.Tables("Stock Control").Rows(selecteditem).Item("PartNo") = txtPartNo.Text
COMP4DataSet.Tables("Stock Control").Rows(selecteditem).Item("Model") = txtModel.Text
COMP4DataSet.Tables("Stock Control").Rows(selecteditem).Item("WholesalerPrice") = txtWholesalerPrice.Text
COMP4DataSet.Tables("Stock Control").Rows(selecteditem).Item("RetailPrice") = txtRetailPrice.Text
COMP4DataSet.Tables("Stock Control").Rows(selecteditem).Item("SupplierUsed") = txtSupplierUsed.Text
COMP4DataSet.Tables("Stock Control").Rows(selecteditem).Item("Quantity") = txtQuantity.Text
COMP4DataSet.Tables("Stock Control").Rows(selecteditem).Item("ReOrderLevel") = txtReOrderLevel.Text
dbdataAdapter.Update(COMP4DataSet, "dtStockControl")
MsgBox("Data was successfully edited", "Stock Control")
End Sub