5
Reply

How do I delete a row from a DataTable?

Mohan Gupta

Mohan Gupta

11y
1.8k
0
Reply

    YourDataTable.AcceptChanges(); foreach (DataRow row in YourDataTable.Rows) {// If this row is offensive thenrow.Delete();} YourDataTable.AcceptChanges();

    YourDataTable.AcceptChanges(); foreach (DataRow row in YourDataTable.Rows) {// If this row is offensive thenrow.Delete();} YourDataTable.AcceptChanges();

    RemoveAt()

    DataRow dr = dt.Rows[0] as DataRow;if (dr["id"].Equals(1)){dr.Delete();}dt.AcceptChanges();

    The below code will help you to delete the recode from a datatable

    DataRow[] drr = dt.Select("Student=' " + id + " ' ");

    for (int i = 0; i < drr.Length; i++)
    drr[i].Delete();


    dt.AcceptChanges();

    asp-net-corner.blogspot.in/