split a datatable based on number of rows code example
Example 1: split a datatable based on number of rows
DataTable[] splittedtables = tbl.AsEnumerable()
.Select((row, index) => new { row, index })
.GroupBy(x => x.index / 12) // integer division, the fractional part is truncated
.Select(g => g.Select(x => x.row).CopyToDataTable())
.ToArray();
Example 2: split a datatable based on number of rows
List<DataTable> result = DTHead.AsEnumerable()
.GroupBy(row => row.Field<int>("MIVID"))
.Select(g => g.CopyToDataTable())
.ToList();