zoukankan      html  css  js  c++  java
  • GRIDVIEW FOOTER 多行 合并

    在gridview的RowCreated的事件里面写下如下代码

     if (e.Row.RowType == DataControlRowType.Footer)
                {
                    TableCellCollection tcc = e.Row.Cells;
                    //this.GridViewProjectGroupQuatityView.FooterRow.Cells.Add(new TableCell());
                    tcc.Clear();

                    e.Row.Cells.Add(new TableCell());
                    e.Row.Cells[0].Attributes.Add("colspan","4");
                    e.Row.Cells[0].Text = "平均值";
                    e.Row.Cells[0].HorizontalAlign = HorizontalAlign.Center;

                    e.Row.Cells.Add(new TableCell());
                    e.Row.Cells[1].BackColor = TransColor("#F2F2F0");
                    e.Row.Cells[1].Text = "";//

                    e.Row.Cells.Add(new TableCell());
                    e.Row.Cells[2].BackColor = TransColor("#F2F2F0");
                    e.Row.Cells[2].Text = "";//

                    e.Row.Cells.Add(new TableCell());
                    e.Row.Cells[3].BackColor = TransColor("#F2F2F0");
                    e.Row.Cells[3].Text = "";//

                    e.Row.Cells.Add(new TableCell());
                    e.Row.Cells[4].BackColor = TransColor("#F2F2F0");
                    e.Row.Cells[4].Text = "";//

                    e.Row.Cells.Add(new TableCell());
                    e.Row.Cells[5].BackColor = TransColor("#F2F2F0");
                    e.Row.Cells[5].Text = "";//

                    e.Row.Cells.Add(new TableCell());
                    e.Row.Cells[6].BackColor = TransColor("#F2F2F0");
                    e.Row.Cells[6].Text = "";//

                    e.Row.Cells.Add(new TableCell());
                    e.Row.Cells[7].BackColor = TransColor("#F2F2F0");
                    e.Row.Cells[7].Text = "";

                    e.Row.Cells.Add(new TableCell());
                    e.Row.Cells[8].BackColor = TransColor("#F2F2F0");
                    e.Row.Cells[8].Text = "";

                    e.Row.Cells.Add(new TableCell());
                    e.Row.Cells[9].BackColor = TransColor("#F2F2F0");
                    e.Row.Cells[9].Text = "";

                    e.Row.Cells.Add(new TableCell());
                    e.Row.Cells[10].BackColor = TransColor("#F2F2F0");
                    e.Row.Cells[10].Text = "";

                    e.Row.Cells.Add(new TableCell());
                    e.Row.Cells[11].BackColor = TransColor("#F2F2F0");
                    e.Row.Cells[11].Text = "";

                    e.Row.Cells.Add(new TableCell());
                    e.Row.Cells[12].BackColor = TransColor("#F2F2F0");
                    e.Row.Cells[12].Text = "</th></tr><tr>";//注意这里,要换行了哦!


                    e.Row.Cells.Add(new TableCell());
                    e.Row.Cells[13].Attributes.Add("colspan", "4");
                    e.Row.Cells[13].Text = "总值";
                    e.Row.Cells[13].HorizontalAlign = HorizontalAlign.Center;

                    e.Row.Cells.Add(new TableCell());
                    e.Row.Cells[14].BackColor = TransColor("#F2F2F0");
                    e.Row.Cells[14].Text = "";

                    e.Row.Cells.Add(new TableCell());
                    e.Row.Cells[15].BackColor = TransColor("#F2F2F0");
                    e.Row.Cells[15].Text = "";


                    e.Row.Cells.Add(new TableCell());
                    e.Row.Cells[16].BackColor = TransColor("#F2F2F0");
                    e.Row.Cells[16].Text = "";

                    e.Row.Cells.Add(new TableCell());
                    e.Row.Cells[17].BackColor = TransColor("#F2F2F0");
                    e.Row.Cells[17].Text = "";


                    e.Row.Cells.Add(new TableCell());
                    e.Row.Cells[18].BackColor = TransColor("#F2F2F0");
                    e.Row.Cells[18].Text = "";

                    e.Row.Cells.Add(new TableCell());
                    e.Row.Cells[19].BackColor = TransColor("#F2F2F0");
                    e.Row.Cells[19].Text = "";

                    e.Row.Cells.Add(new TableCell());
                    e.Row.Cells[20].BackColor = TransColor("#F2F2F0");
                    e.Row.Cells[20].Text = "";

                    e.Row.Cells.Add(new TableCell());
                    e.Row.Cells[21].BackColor = TransColor("#F2F2F0");
                    e.Row.Cells[21].Text = "";

                    e.Row.Cells.Add(new TableCell());
                    e.Row.Cells[22].BackColor = TransColor("#F2F2F0");
                    e.Row.Cells[22].Text = "";

                    e.Row.Cells.Add(new TableCell());
                    e.Row.Cells[23].BackColor = TransColor("#F2F2F0");
                    e.Row.Cells[23].Text = "";

                    e.Row.Cells.Add(new TableCell());
                    e.Row.Cells[24].BackColor = TransColor("#F2F2F0");
                    e.Row.Cells[24].Text = "";

                    e.Row.Cells.Add(new TableCell());
                    e.Row.Cells[25].BackColor = TransColor("#F2F2F0");
                    e.Row.Cells[25].Text = "";
                 
               
                }

    效果如图gridview多行footer,并且合并footer单元格

  • 相关阅读:
    React新闻网站--Header组件拆分及样式布局
    React 中的前端路由 react-router-dom
    Bootstrap4 图像形状+Jumbotron+信息提示框+按钮
    Bootstrap4 表格练习
    React好帮手--Ant Design 组件库的使用
    React 中的生命周期函数
    React 中 ref 的使用
    深入理解 Java 线程池
    Elastic 技术栈之 Filebeat
    mysql 开发进阶篇系列 54 权限与安全(账号管理的各种权限操作 下)
  • 原文地址:https://www.cnblogs.com/huanghai223/p/2043273.html
Copyright © 2011-2022 走看看