Implementation method of C deleting a row according to conditions in DataTable
- 2021-10-11 19:22:43
- OfStack
We often put the data source in DataTable, but sometimes we need to remove unwanted rows. The following code tells you
DataTable dts ;
DataRow[] foundRow;
foundRow = dts.Select("ID=99", "");
foreach (DataRow row in foundRow)
{
dts.Rows.Remove(row);
}
In fact, it is the Select method of DataTable
The above is how to remove a line 1 in Datatable if id is 99, and id is the field name
The above code simple implementation of c # datatable deletion of a line of implementation, I hope to help everyone!