<source lang="csharp" line="1">
private DataTable GetPageData(int pageSize, int pageIndex)
{
DataTable source = this.SourceTable;
int startIndex = (pageIndex - 1) * pageSize;
int endIndex;
if (startIndex + pageSize > source.Rows.Count)
endIndex = source.Rows.Count;
else
endIndex = startIndex + pageSize;
DataTable pageData = new DataTable();
for (int i = 0; i < source.Columns.Count; i++)
{
pageData.Columns.Add(source.Columns[i].ColumnName, source.Columns[i].DataType);
}
for (int i = startIndex; i < endIndex; i++)
{
object[] newrow = new object[source.Columns.Count];
pageData.Rows.Add(source.Rows[i].ItemArray);
}
return pageData;
}
</source>