Wednesday, September 9, 2009

Trim Table

public static DataTable TrimDataTable(DataTable dataTable, int noOfRows)

{

DataRow[] dataRows = dataTable.Select();

DataTable filteredDataTable = dataTable.Clone();

for (int i = 0; i < dataRows.Length; i++)

{

filteredDataTable.ImportRow(dataRows[i]);

if (i >= noOfRows - 1)

break;

}

return filteredDataTable;

}

No comments: