List
protected List<T> ListPager<T>(List<T> DataSource, int CurrentPageIndex, int PageSize, string FilterExpression, refint 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);
}
}

 

相关文章:

  • 2021-11-17
  • 2022-02-17
  • 2022-01-02
  • 2021-12-22
  • 2021-12-19
  • 2021-12-18
  • 2021-11-21
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-11-28
  • 2022-12-23
  • 2022-12-23
  • 2021-05-26
相关资源
相似解决方案