List
Protected List < T > Listpager < T > (List < T > 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 < T > (Datasource );
Dataview dv = DT. defaultview;
DV. rowfilter = Filterexpression;
List < T > Newdatasource = Kinglib. datahelper. datatabletolist < T > (DV. totable ());
Count = Newdatasource. count;
Int Startindex = Currentpageindex * Pagesize;
If (Startindex + Pagesize > Newdatasource. Count)
{
Pagesize = Newdatasource. Count - Startindex;
}
Return Newdatasource. getrange (startindex, pagesize );
}
}