zoukankan      html  css  js  c++  java
  • GridView相同内容合并单元格

    using System;
    using System.Data;
    using System.Configuration;
    using System.Collections;
    using System.Web;
    using System.Web.Security;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.Web.UI.WebControls.WebParts;
    using System.Web.UI.HtmlControls;

    public partial class main : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {   // bind();
            Gridview_RowSpan(GridView1);

        }
      
       


     
        public static void Gridview_RowSpan(System.Web.UI.WebControls.GridView gv)
        {
            //合并单元格
            for (int i = 0; i < gv.Rows.Count - 1; i++)
            {
                int colnum = 1;
                int j;
                for (j = i + 1; j < gv.Rows.Count; j++)
                {
                    if (gv.Rows[i].Cells[0].Text == gv.Rows[j].Cells[0].Text)
                    {
                        colnum++;
                        gv.Rows[i].Cells[0].RowSpan = colnum;
                        gv.Rows[j].Cells[0].Visible = false;
                        gv.Rows[i].Cells[1].RowSpan = colnum;
                        gv.Rows[j].Cells[1].Visible = false;
                        gv.Rows[i].Cells[2].RowSpan = colnum;
                        gv.Rows[j].Cells[2].Visible = false;
                        gv.Rows[i].Cells[3].RowSpan = colnum;
                        gv.Rows[j].Cells[3].Visible = false;
                        gv.Rows[i].Cells[4].RowSpan = colnum;
                        gv.Rows[j].Cells[4].Visible = false;
                        gv.Rows[i].Cells[5].RowSpan = colnum;
                        gv.Rows[j].Cells[5].Visible = false;
                        gv.Rows[i].Cells[6].RowSpan = colnum;
                        gv.Rows[j].Cells[6].Visible = false;
                        gv.Rows[i].Cells[7].RowSpan = colnum;
                        gv.Rows[j].Cells[7].Visible = false;
                        gv.Rows[i].Cells[8].RowSpan = colnum;
                        gv.Rows[j].Cells[8].Visible = false;
                    }
                    else
                        break;
                }
                i = j - 1;
            }
        }

    }

  • 相关阅读:
    树状数组与线段树基础
    阿里云服务器低价购买及域名解析
    ENVI5.3安装教程(含软件下载)
    05 ArcGIS JS API 4.12版本监听view-change事件
    jQuery的AJAX请求成功,但是跳转到error的解决方法
    04 ArcGIS JS API 4.12加载天地图
    02 Portal for ArcGIS 10.7安装部署教程(linux环境)
    10 webpack4.0学习笔记——热替换_devServer
    09 webpack4.0学习笔记——配置文件_HtmlWebpackPlugin使用
    08 webpack4.0学习笔记——配置文件_DefinePlugin使用
  • 原文地址:https://www.cnblogs.com/dujinyang/p/4815580.html
Copyright © 2011-2022 走看看