To Break a Data table

You can use the following approach to break a data table.

Assuming the data table contains 10 rows.

count = 10

  1. halfCount = count/2 = 5
  2. newdt1= myDataTable.AsEnumerable().Skip(0).Take(halfCount).CopyToDataTable

newdt2= myDataTable.AsEnumerable().Skip(halfCount).Take(halfCount).CopyToDataTable

newdt1 contains first 5 rows
newdt2 contains last 5 rows

Skip - Will skip the given number of rows
Take - Will take the next given number of rows

Regards,
Karthik Byggari

4 Likes