SoFunction
Updated on 2025-03-06

C# datatable cannot access the information processing method of the deleted row.

The reasons are as follows:

After Delete(), the() method needs to confirm the complete deletion, because Delete() just flags the status flag of the corresponding column as delete.
You can also roll back through () to make the line undelete.

If you want to completely delete the datarow, you need to use the Delete() and AccepteChanges() methods at the same time, or use the (i) method to delete it directly.
where i represents the row index, and another is (DataRow dr) to delete the specified row.

However, use (i) and be careful if used continuously (0); (1);
At this time, it is not that the 0 and 1 rows in the original table are deleted, but that after the 0 rows are deleted, the original 1 row becomes 0 rows, so (1) the actual deleted are 2 rows in the original table.
Therefore, you should still use (i). If you want to delete multiple lines, you can use Delete() continuously, and then use the AccepteChanges() method to confirm the deletion.

Solution Example:

Copy the codeThe code is as follows:

List<string> lst = new List<string>();
for (int i = 0; i < _Table.; i++)
{
if (_Table.Rows[i].RowState!=)
{
(_Table.Rows[i]["I_SL"].ToString() == "0" ? "false" : "true");
}
}