The reasons are as follows:
The DataTable is required after Delete (). The Acceptechanges () method confirms a complete deletion, because delete () simply flags the status of the corresponding column as deleted.
You can also pass the DataTable. RejectChanges () rollback, causing the row to be removed.
If you want to completely remove DataRow, you need the Delete () and acceptechanges () methods to be used at the same time, or in a DataTable. Rows.removeat (i) method is directly deleted,
Where I represents the row index, and one is the DataTable. Rows.remove (DataRow DR) deletes the specified line.
But use a DataTable. Rows.removeat (i) Note that if the DataTable is used continuously. Rows.removeat (0), DataTable. Rows.removeat (1);
This is not the deletion of the original table of 0, 1 rows, but delete 0 rows, the original 1 rows into 0 rows, so the DataTable. Rows.removeat (1) actually deletes 2 rows from the original table.
So be careful with the DataTable. Rows.removeat (i), to delete multiple rows, you can use Delete () consecutively, and then use the Acceptechanges () method to confirm the deletion.
Solution Example:
Copy Code code as follows:
list<string> lst = new list<string> ();
for (int i = 0; i < _table.rows.count; i++)
{
if (_table.rows[i). rowstate!=datarowstate.deleted)
{
lst. ADD (_table.rows[i]["I_SL"]. ToString () = = "0"? "False": "true");
}
}