M
Michael Wong
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;
dataGridView.Rows.Remove(row);
}
Debug.WriteLine(myTypedDataset.myTypedDataTable.Rows.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
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;
dataGridView.Rows.Remove(row);
}
Debug.WriteLine(myTypedDataset.myTypedDataTable.Rows.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