![]() | |
![]() |
| | Thread Tools | Search this Thread | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
I have a DataGridView which is bound to a dataset. When I delete rows from the DataGridView, should it delete the same rows from the dataset also? I have tried the following code, but apparently, the dataset isn't updated. Did I miss (understood) something? for(int i = 0; i < dataGridView.SelectedRows.Count; i++) { DataGridViewRow row = dataGridView.SelectedRows[i]; dataGridView.Rows.Remove(row); } |
|
Debug.WriteLine(myTypedDataset.myTypedDataTable.Ro ws.Count.ToString()); // Here, the count is the same as before the deletion, but when // accessing the dataTable rows, a // DeletedRowInaccessibleException occurs on the deleted rows |
#3
| |||
| |||
|
|
Use something like: while (tbl_masterDataGridView.SelectedRows.Count > 0) tbl_masterDataGridView.Rows.Remove(tbl_masterDataG ridView.SelectedRows[0]); Or use the For index backwards |
#4
| |||
| |||
|
|
for(int i = dataGridView.SelectedRows.Count; i < 0; i--) |
#5
| |||
| |||
|
|
| for(int i = dataGridView.SelectedRows.Count; i < 0; i--) or possibly for(int i = dataGridView.SelectedRows.Count; i > 0; i--) might work better :-)) Without any doubt |
#6
| |||
| |||
|
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
| |