• 统计合并griview2


      注:将ShowFooter属性设置为true

           int mysum1 = 0;
            Double mysum2 = 0;
            protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
            {
                if (e.Row.RowType == DataControlRowType.DataRow)
                {
                    DataRowView myrows = (DataRowView)e.Row.DataItem;

                      //要统计总数的列
                    mysum1 += Convert.ToInt32(myrows[8].ToString());
                    mysum2 += Convert.ToDouble(myrows[9].ToString());
                }
                // 合计
                //if (e.Row.RowType == DataControlRowType.Footer)
                //{
                //    e.Row.Cells[0].Text = "合计";
                //    e.Row.Cells[8].Text = "总本数:" + mysum1.ToString();
                //    e.Row.Cells[9].Text =mysum2.ToString();
                //}
            }

          //合并单元格

            protected void GridView1_RowCreated(object sender, GridViewRowEventArgs e)
            {

              //判断是否是表脚
                if (e.Row.RowType == DataControlRowType.Footer)
                {

                    //获取表脚所在的所有单元格
                    TableCellCollection TableCell = e.Row.Cells;

                  //自动清除表脚
                    TableCell.Clear();
                    TableCell.Add( new TableHeaderCell() );
                    TableCell[0].Text = "合计:";

                    TableCell.Add(new TableHeaderCell());
                    TableCell[1].ColumnSpan =8;                          //合并行,要和并列是需设置RowSpan  ;从第二个单元格一次后合并8个
                    TableCell[1].Text = "书本数总计:" + mysum1.ToString()+"本";

                    TableCell.Add(new TableHeaderCell());
                    TableCell[2].ColumnSpan = 2;
                    TableCell[2].Text = "实样总计:" + mysum2.ToString()+"元";
                }
            }

  • 相关阅读:
    java javax.annotation.Resource注解的详解
    Struts2注解详解
    HDU 5074-Hatsune Miku(DP)
    Mac下配置Cocos2d-x3.1环境
    POJ 2109 Power of Cryptography
    Swift编程语言学习10—— 枚举属性监视器
    解决:Determining IP Information for eth0 一直停留 无法进入系统
    Bootstrap之表格
    创建和关联内容数据库到指定Web应用程序和站点集
    Ucan23操作系统项目地址
  • 原文地址:https://www.cnblogs.com/happygx/p/1957932.html
Copyright © 2020-2023  润新知