DataTable DataTable1 = SqlHelper.GetDataTable("select convert(char(5),id) As 'id' ,num from testSum");
        DataTable DataTable2 = SqlHelper.GetDataTable("select '统计',Sum(num) from testSum");
        DataTable newDataTable = DataTable1.Clone();

        object[] obj = new object[newDataTable.Columns.Count];
        for (int i = 0; i < DataTable1.Rows.Count; i++)
        {
            DataTable1.Rows[i].ItemArray.CopyTo(obj, 0);
            newDataTable.Rows.Add(obj);
        }
        for (int i = 0; i < DataTable2.Rows.Count; i++)
        {
            DataTable2.Rows[i].ItemArray.CopyTo(obj, 0);
            newDataTable.Rows.Add(obj);
        }
        GridView1.DataSource = newDataTable;
        GridView1.DataBind();

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-11-02
猜你喜欢
  • 2022-12-23
  • 2022-02-19
  • 2022-12-23
  • 2021-05-18
相关资源
相似解决方案