```csharp
private DataTable GetPagedTable(DataTable dt, int pageIndex, int pageSize)
{
if (pageIndex == 0)
return dt;
DataTable newDt = dt.Copy();
newDt.Clear();
int rowBegin = (pageIndex - 1) * pageSize;
int rowEnd = pageIndex * pageSize;
if (rowBegin >= dt.Rows.Count)
{
return newDt;
}
if (rowEnd > dt.Rows.Count)
{
rowEnd = dt.Rows.Count;
}
for (int i = rowBegin; i <= rowEnd - 1; i++)
{
DataRow newDr = newDt.NewRow();
DataRow dr = dt.Rows[i];
foreach (DataColumn column in dt.Columns)
newDr[column.ColumnName] = dr[column.ColumnName];
newDt.Rows.Add(newDr);
}
return newDt;
}
```