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

  • 相关阅读:
    python_元素定位
    python_html_初识
    python_selenium_初识
    python_jenkins_集成
    python_正则表达式_re
    python_接口关联处理与pymysql中commit
    python_json与pymsql模块
    python_接口请求requests模块
    Codeforces Round #656 (Div. 3) D. a-Good String
    Codeforces Round #656 (Div. 3) C. Make It Good
  • 原文地址:https://www.cnblogs.com/tyl2008/p/2120904.html
Copyright © 2011-2022 走看看