zoukankan      html  css  js  c++  java
  • 在datatable中添加一序号列

    http://topic.csdn.net/t/20050324/09/3876414.html
    int colLength = dt.Rows.Count;
                
    int rowLength = dt.Columns.Count;
                DataRow
    [] newRows = new DataRow[rowLength];
                DataTable subDT 
    = new DataTable();
               
                
    for (int i = 0; i < colLength; i++)
                {
                    subDT.Columns.
    Add();
                    
    for (int j = 0; j < rowLength; j++)
                    {
                        
                        
    if (newRows[j] == null) newRows[j] = subDT.NewRow();
                        newRows
    [j][i] = dt.Rows[i][j];

                    }
                }
                foreach (DataRow row 
    in newRows)
                {
                    subDT.Rows.
    Add(row);
                }
                DataRow dr 
    = subDT.NewRow();   
           dr
    [0]="aaa";   
           dr
    [1]="bbb";
           subDT.Rows.
    Add(dr);


                GridView3.DataSource 
    = subDT;
                GridView3.DataBind();
  • 相关阅读:
    python 中的[::-1]
    python 闭包
    elastic
    文件上传进度条修改
    python decorator的理解
    同方爬虫--面试题
    js typeof
    浅谈软件项目实施
    数独·唯一性技巧(Uniqueness)-1
    数独二
  • 原文地址:https://www.cnblogs.com/wdx2008/p/779605.html
Copyright © 2011-2022 走看看