Interviews5 answers
How do I delete a row from a DataTable?
5 Answers
YourDataTable.AcceptChanges();
foreach (DataRow row in YourDataTable.Rows) {
// If this row is offensive then
row.Delete();
}
YourDataTable.AcceptChanges();
Bharathi RajaPosted Jan 19, 2018, 8:29 PM EST
YourDataTable.AcceptChanges();
foreach (DataRow row in YourDataTable.Rows) {
// If this row is offensive then
row.Delete();
}
YourDataTable.AcceptChanges();
Bharathi RajaPosted Jan 19, 2018, 8:29 PM EST
RemoveAt()
Sunil BabuPosted Apr 3, 2016, 4:18 AM EDT
DataRow dr = dt.Rows[0] as DataRow;
if (dr["id"].Equals(1))
{
dr.Delete();
}
dt.AcceptChanges();
Lalit RaghavPosted May 12, 2015, 11:39 PM EDT
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/
DataRow[] drr = dt.Select("Student=' " + id + " ' ");
for (int i = 0; i < drr.Length; i++)
drr[i].Delete();
dt.AcceptChanges();
asp-net-corner.blogspot.in/
vijay sekaranPosted Jul 1, 2013, 9:09 PM EDT

