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;
            }
        }

    }

  • 相关阅读:
    RPC之Thrift系列1-----Thrit介绍
    MYSQL-实现sqlserver- row_number() over(partition by order by) 分组排序功能
    Sql Server 中 PIVOT在mysql 中的实现
    MSSQL中 ROW_NUMBER() OVER(PARTITION BY COLUMN ORDER BY COLUMN)在Mysql中的实现
    mysql判断表中符合条件的记录是否存在
    mysql对树进行递归查询
    MySql5.6中的表按照时间进行表分区过程中遇到的坑
    .net平台上实现数据库访问工厂,连接不同的数据库
    VS静态编译与动态编译
    CRC原理阐述
  • 原文地址:https://www.cnblogs.com/dujinyang/p/4815580.html
Copyright © 2011-2022 走看看