From: Http://blog.csdn.net/soulscarrier
Protected list Listpager (list DataSource, int currentpageindex, int PageSize, string filterexpression, ref int count)
{
Count = 0;
if (DataSource = = NULL | | Datasource.count = = 0)
return DataSource;
Count = Datasource.count;
if (string. IsNullOrEmpty (FilterExpression))
{
int startIndex = CurrentPageIndex * PageSize;
if (StartIndex + PageSize > Datasource.count)
{
PageSize = Datasource.count-startindex;
}
Return Datasource.getrange (StartIndex, PageSize);
}
Else
{
DataTable dt = KingLib.DataHelper.ListToDataTable (DataSource);
DataView dv = dt. DefaultView;
Dv. RowFilter = FilterExpression;
List Newdatasource = KingLib.DataHelper.DataTableToList (dv. ToTable ());
Count = Newdatasource.count;
int startIndex = CurrentPageIndex * PageSize;
if (StartIndex + PageSize > Newdatasource.count)
{
PageSize = Newdatasource.count-startindex;
}
Return Newdatasource.getrange (StartIndex, PageSize);
}
}
list<t> paging mode, generic paging mode