Deleting from DataGrid (bound to dataset)

mcerk

Well-known member
Joined
Nov 1, 2004
Messages
78
OK. I want to delete rows from DataGrid. Im doing it like this:
Code:
Dim RowNumber as integer
RowNumber = Me.BindingContext(DataSet.Table1).Position
Me.DataSet.Table1.Rows(RowNumber).Delete

So, row number Me.BindingContext(DataSet.Table1).Position is marked for deletion (it alsso disapears from DataGrid). The row is deleted, when I update DataSet from DataAdapter.

OK, It is all right through this point. But....

If I delete row nr. 8 (Me.BindingContext(DataSet.Table1).Position=8), then row nr. 9 gets number 8. And so on. I can not delete all rows using this method.

So my question is. How can I define real row number. ????

PS: Im deleteing selected row (in datagrid) by pressing a button.
 
What? You dont delete from the Datagrid, you delete from the Dataset bound to the datagrid. Treat the dataset as if it were a database and send it sql commands accordingly.
 
Ok, not Sql commands, but you can do everything through the dataset object that you can do with Sql. Are you showing one record at a time? After you delete the record are you calling dataAdapter.Update(dataSet)? Are the UPDATE, DELETE and INSERT commands set?
 
Back
Top