• DataTable拆分分页


     public 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];
                    }
                   
                }
                return newdt;
            }

  • 相关阅读:
    python小记(4)
    python小记(3)
    python小记(2)
    python小记(1)
    Linux学习
    plist文件的 偏好设置 存储与读取 自定义对象归档
    控制器创建的三种方式
    IOS应用启动过程
    pch文件中自定义log
    textLabel辅助试图及toolBar创建使用
  • 原文地址:https://www.cnblogs.com/aweifly/p/2741593.html
Copyright © 2020-2023  润新知