You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
35 lines
1.0 KiB
C#
35 lines
1.0 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Data;
|
|
using System.Text;
|
|
|
|
namespace Estsh.Core.Util
|
|
{
|
|
public static class DataTableHelper
|
|
{
|
|
public static DataTable GetTablePage(ref Pager pager, DataTable dt)
|
|
{
|
|
DataTable result = dt.Clone();
|
|
|
|
if (dt != null && dt.Rows.Count > 0 && pager.pageNo >= 0)
|
|
{
|
|
int startIndex = (pager.pageNo - 1) * pager.pageSize;
|
|
int endIndex = startIndex + pager.pageSize;
|
|
for (; startIndex < endIndex && startIndex < dt.Rows.Count; startIndex++)
|
|
{
|
|
DataRow resDr = result.NewRow();
|
|
DataRow dr = dt.Rows[startIndex];
|
|
for (int idx = 0; idx < dt.Columns.Count; idx++)
|
|
{
|
|
resDr[idx] = dr[idx];
|
|
}
|
|
|
|
result.Rows.Add(resDr);
|
|
}
|
|
}
|
|
pager.totalRows = dt.Rows.Count;
|
|
return result;
|
|
}
|
|
}
|
|
}
|