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);
                }
            }

  • 相关阅读:
    super的使用
    Django--自定义 Command 命令
    Django models
    二柱子的编程 四则运算2
    阅读《梦断代码》计划
    随机数计算小学四则运算
    人月神话有感
    软件演化
    软件测试
    软件实现
  • 原文地址:https://www.cnblogs.com/tyl2008/p/2120904.html
Copyright © 2011-2022 走看看