I will extend previous example in which I have explained you that how to create a DataTable in asp.net.
You can delete rows from a data table by using Delete Method. After deleting row, you have to call AcceptChanges Method to commit all changes in datatable. In this example. I have deleted 2nd row as i have passed 1st index of the row because index count start from the zero.
Here’s an example
DataTable dt = new DataTable();
DataRow dr = null;
dt.Columns.Add(new DataColumn("FullName", typeof(string)));
dt.Columns.Add(new DataColumn("Age", typeof(Int16)));
for (int i = 0; i < 10; i++)
{
dr = dt.NewRow();
dr["FullName"] = String.Format("Aamir Hasan_{0}", i.ToString());
dr["Age"] = 20;
dt.Rows.Add(dr);
}
int oldtotal = dt.Rows.Count;
dt.Rows[1].Delete();
dt.AcceptChanges();
int newtotal = dt.Rows.Count;
Output
