Help talk:Contents

From Catglobe Wiki
Revision as of 09:45, 22 December 2008 by Catglobe (talk | contribs) (New page: <source lang="csharp" line="1"><br>private DataTable GetPageData(int pageSize, int pageIndex)<br>{<br>DataTable source = this.SourceTable;<br>int startIndex = (pageIndex - 1) * pageS...)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

<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>