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

    //分割DataTable
            private IList<DataTable> ListData()
            {
                //按DIVIDER分割
                List<DataTable> dtList = new List<DataTable>();
                const int DIVIDER = 5;
                DataTable dtData = (DataTable)this.Session["Table"];
                for (int i = 0; i < Math.Ceiling(dtData.Columns.Count / (double)DIVIDER); i++)
                {
                    DataTable subdt = new DataTable();
                    dtData.Columns.Cast<DataColumn>().Skip(DIVIDER * i).Take(DIVIDER).Select(cl => cl.ColumnName).ToList().ForEach(name => subdt.Columns.Add(name));
                    dtList.Add(subdt);
                }
                foreach (DataRow row in dtData.Rows)
                    dtList.ForEach(dt => dt.ImportRow(row));
                return dtList;
            }

            private void DisplayGrid()
            {
                IList<DataTable> listdt = ListData();
                foreach (DataTable dt in listdt)
                {
                    GridView gv = new GridView();
                    gv.DataSource = dt;
                    gv.DataBind();
                    PlaceHolder1.Controls.Add(gv);
                }
            }

  • 相关阅读:
    .net网络编程(4)TcpListener、TcpClient
    Win32 窗口篇(1)
    Win32 窗口篇(3)
    JS数组定义
    asp的RegExp对象正则表达式功能用法
    Javascript 面向对象全新理练之数据的封装
    asp 正则表达式
    PPK 谈 JavaScript 的 this 关键字
    JavaScript 接收键盘指令示例
    javascript事件列表解说
  • 原文地址:https://www.cnblogs.com/tyl2008/p/2120904.html
Copyright © 2011-2022 走看看