أنشئ حسابًا أو سجّل الدخول للانضمام إلى مجتمعك المهني.
‘DataTable’ has “DataRowCollection” object which has all rows in a “DataTable” object.'Add' method of the DataRowCollection is used to add a new row in DataTable.'Remove' method of the DataRowCollection is used to remove a ‘DataRow’ object from ‘DataTable’.'RemoveAt' method of the DataRowCollection is used to remove a ‘DataRow’ object from ‘DataTable’ as per the index specified in the DataTable.
To add new row ,one can simply do this :
// get the DataTable
DataTabel dt = new DataTable();
DataRow dr = dt.NewRow();
dr[0] = "random_data";
.
. .. // so on
dt.Rows.add(dr);
Similary for deleting any row from Datatable :
// dt is your DataTable
for( int iterator i = dt.Rows.Count-1;iterator>=0;iterator--)
{
DataRow dr = dt.Rows[i];
if(dr['yourColName'] == 'yourValue' ) // for conditional deleting , else remove this condition
dr.Delete();
}