"Cannot access information for this row through deleted rows" error after deleting row of DataTable
===========================================================
Use a DataTable. Rows[i]. Delete () When you delete a row and then access the table, the error "information that cannot access the row through a deleted row" appears. The reasons are as follows:
A DataTable is required after Delete (). The Acceptechanges () method confirms a complete deletion, because delete () only flags the status of the corresponding column as deleted, and it can be passed through a DataTable. RejectChanges () rollback to make the row undelete.
So if you want to delete the DataRow completely, you need to use either the Delete () and Acceptechanges () methods, or use a DataTable. The Rows.removeat (i) method is removed directly, where I represents the row index and one is a DataTable. Rows.remove (DataRow DR) deletes the specified line.
However, use a DataTable. Rows.removeat (i) Note that if you are using a DataTable continuously. Rows.removeat (0); a DataTable. Rows.removeat (1); This is not the deletion of the original table in 0, 1 rows, but the deletion of 0 rows, the original 1 lines will become 0 rows, so the DataTable. Rows.removeat (1) actually deletes 2 rows from the original table.
Therefore, we should use the DataTable with caution. Rows.removeat (i), to delete multiple rows, you can use Delete () consecutively and then confirm the deletion with the Acceptechanges () method.
After deleting the row of a DataTable, the error "Cannot access the row's information through a deleted row" appears, that is, deletedrowinaccessibleexception