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();
  • 相关阅读:
    JS知识点简单总结
    Js答辩总结
    JS答辩习题
    轮播
    jQuery选择器总结
    JS的魅力
    JS与JAVA数据类型的区别
    单表查询、多表查询、虚拟表连接查询
    Mysql基本语句
    Mysql数据库
  • 原文地址:https://www.cnblogs.com/wdx2008/p/779605.html
Copyright © 2011-2022 走看看