|
|
(34 intermediate revisions by the same user not shown) |
Line 1: |
Line 1: |
| <source lang="csharp" line="1"><br>private DataTable GetPageData(int pageSize, int pageIndex)<br>{<br>DataTable source = this.SourceTable;<br>int startIndex = (pageIndex - 1) * pageSize;<br>int endIndex;<br>if (startIndex + pageSize > source.Rows.Count)<br>endIndex = source.Rows.Count;<br>else<br>endIndex = startIndex + pageSize;<br><br>DataTable pageData = new DataTable();<br><br>for (int i = 0; i < source.Columns.Count; i++)<br>{<br>pageData.Columns.Add(source.Columns[i].ColumnName, source.Columns[i].DataType);<br>}<br>for (int i = startIndex; i < endIndex; i++)<br>{<br>object[] newrow = new object[source.Columns.Count];<br>pageData.Rows.Add(source.Rows[i].ItemArray);<br>}
| |
|
| |
|
| return pageData;<br>}
| |
|
| |
| </source><br>
| |