zoukankan      html  css  js  c++  java
  • DataTable 分页

     #region DataTable 分页        

    /// <summary>        

    /// Datatable 分页        

    /// </summary>        

    /// <param name="dt"></param>        

    /// <param name="PageIndex">当前页</param>        

    /// <param name="PageSize">页大小</param>        

    /// <returns></returns>        

    public static 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];                

    }                

    newdt.Rows.Add(newdr);            

    }            

    return newdt;        

    }        

    #endregion

  • 相关阅读:
    10大经典排序算法动图演示,看这篇就够了!
    SSM是什么框架?
    SSM框架面试题及答案整理
    SSM框架面试题及答案整理
    SpringMVC工作原理详解
    synchronized关键字的用法总结
    Java常用数据结构之Set之TreeSet
    jQuery学习笔记(简介,选择器)
    你自认为理解了JavaScript?
    JDK1.5新特性,基础类库篇,XML增强
  • 原文地址:https://www.cnblogs.com/zhangxiaolei521/p/5660891.html
Copyright © 2011-2022 走看看