Wednesday, February 23, 2011

Split DataTable in to several DataTables

I achieved this requirement from this code snippet.


public DataTable[] getDataTables(DataTable tableToClone, int seperateVal, int val)
{
 DataTable[] tables = new DataTable[val];
 int count = 0;
 int index = 0;

 DataTable copyTable = null;
 foreach (DataRow row in tableToClone.Rows)
 {
 if ((count++ % seperateVal) == 0)
 {
 copyTable = new DataTable();
 copyTable = tableToClone.Clone();

 tables[index] = copyTable;
 index++;
 }

 copyTable.ImportRow(row);
 }
 return tables;
 } 

No comments:

Post a Comment

How to Create Events Using Microsoft Graph API with Delegated Permissions and MSAL.js

Microsoft Graph API provides powerful capabilities to interact with Microsoft 365 services. In this guide, we’ll explore how to create calen...