Tuesday, May 3, 2011

A Quick Way to Copy a DataRow in C#


DataTable NewDataTable= OriginalDataTable.Clone();//This Line Creates new Table with the same structure as the old table

for(int i=0;i<OriginalDataTable.Rows.Count;i++)
{
  NewDataTable.ImportRow(OriginalDataTable.Rows[i]);//This line copy's the row into new table
}

No comments:

Post a Comment