zoukankan      html  css  js  c++  java
  • List<T> 分页方式,泛型分页方式

    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);
    }
    }
    千人.NET交流群:18362376,因为有你,代码变得更简单,加群请输入cnblogs
  • 相关阅读:
    软件测试常见概念
    Apollo简介及工作原理
    bug的编写技巧与级别划分
    native与H5优缺点及H5测试
    优惠券测试
    go语言-for循环
    go语言-流程控制--if
    go语言-二进制与位运算
    cookie和session
    AJAX
  • 原文地址:https://www.cnblogs.com/kingkoo/p/2116946.html
Copyright © 2011-2022 走看看