How to retrieve some records from the DataTable

Posted by Amatya under C# category on | Points: 40 | Views : 904
Here we are assuming that DataTable dt are having 20 records and from that dt we want to retrieve only first 10 records.

The below code snippet will work in this case

private DataTable GethreeRows(DataTable dt)
DataTable newdt = dt.Clone();
for(int i=0;i<10;i++)
DataRow row = dt.Rows[i];
newdt .Rows.Add(row);
return newdt ;

Hope it will help you guys.

Comments or Responses

Login to post response