title: Split datatable into multiple fixed sized tables
body: <p>I have a data table which has 1123 records. I want to split this table into 5 fixed size separate datatables. Size limit for each table is 225.</p>
  
  <p>So size of resulting datatables will be:</p>
  
  <pre><code>DT1 : 225 rows
  DT2 : 225 rows
  DT3 : 225 rows
  DT4 : 225 rows
  DT5 : 223 rows (remaining rows)
  </code></pre>
  
  <p>I was able to find how to split datatable based on the column value using LINQ <a href="https://stackoverflow.com/questions/12740353/split-a-datatable-into-2-or-more-datatables-based-on-column-value">here</a>. </p>
  
  <p>I also found a way to split datatable into multiple tables <a href="http://www.c-sharpcorner.com/blogs/splitting-a-large-datatable-into-smaller-batches1" rel="noreferrer">here</a>. Wanted to know if there's a better way of doing this. Posting code form the link:</p>
  
  <pre><code>private static List&lt;DataTable&gt; SplitTable(DataTable originalTable, int batchSize)
  {
       List&lt;DataTable&gt; tables = new List&lt;DataTable&gt;();
       int i = 0;
       int j = 1;
      DataTable newDt = originalTable.Clone();
     newDt.TableName = "Table_" + j;
     newDt.Clear();
      foreach (DataRow row in originalTable.Rows)
      {
           DataRow newRow = newDt.NewRow();
           newRow.ItemArray = row.ItemArray;
           newDt.Rows.Add(newRow);
           i++;
           if (i == batchSize)
          {
             tables.Add(newDt);
             j++;
            newDt = originalTable.Clone();
            newDt.TableName = "Table_" + j;
            newDt.Clear();
            i = 0;
        }
    }
     return tables;
  }
  </code></pre>
  
  <p>Need help in splitting datatable into fixed size.</p>