Tuesday, December 4, 2007

Copy Dataset to another Dataset or Table to Table

if We need to copy Dataset contain to another data set we can use copy() method belong to that data set...

private void loadDtagrideview (DataSet ds) // this DataSet retun by another method
{


DataTable table1 = ds.Tables[0].Copy();

table1.Clear(); //remain the structure of the table without data

foreach (DataRow dr in ds.Tables[0].Rows)

{
if( some condition)// copy only the data if the condition true
{

table1.Rows.Add(dr.ItemArray);// only selected rows ..
}
}
}

No comments:

Post a Comment