• GrideView合并列合并序号,隐藏某列按钮


    合并编号列 
    /// <summary> 
        /// 合并GridView中某列相同信息的行(单元格) 
        /// </summary> 
        /// <param name="GridView1">GridView</param> 
        /// <param name="cellNum">第几列</param> 
        public static void FilLRowsNO(GridView GridView1, int cellNum)
        {
            int i = 0, rowSpanNum = 1;
            int no = 0;
            while (i < GridView1.Rows.Count - 1)
            {
                GridViewRow gvr = GridView1.Rows[i];
                for (++i; i < GridView1.Rows.Count; i++)
                {
                    GridViewRow gvrNext = GridView1.Rows[i];
                    if (gvr.Cells[cellNum].Text == gvrNext.Cells[cellNum].Text)
                    {
                        gvrNext.Cells[0].Visible = false;
                        rowSpanNum++;
                    }
                    else
                    {
                        gvr.Cells[0].RowSpan = rowSpanNum;
                        no = no + 1;
                        gvr.Cells[0].Text = no.ToString();
    
    
    
                        rowSpanNum = 1;
                        break;
                    }
                    if (i == GridView1.Rows.Count - 1)
                    {
                        gvr.Cells[0].RowSpan = rowSpanNum;
                        no = no + 1;
                        gvr.Cells[0].Text = no.ToString();
    
                    }
                }
            }
        }
    合并数据列
        /// <summary> 
        /// 合并GridView中某列相同信息的行(单元格) 
        /// </summary> 
        /// <param name="GridView1">GridView</param> 
        /// <param name="cellNum">第几列</param> 
        public static void GroupRows(GridView GridView1, int cellNum)
        {
            int i = 0, rowSpanNum = 1;
            while (i < GridView1.Rows.Count - 1)
            {
                GridViewRow gvr = GridView1.Rows[i];
                for (++i; i < GridView1.Rows.Count; i++)
                {
                    GridViewRow gvrNext = GridView1.Rows[i];
                    if (gvr.Cells[cellNum].Text == gvrNext.Cells[cellNum].Text)
                    {
                        gvrNext.Cells[cellNum].Visible = false;
                        rowSpanNum++;
                    }
                    else
                    {
                        gvr.Cells[cellNum].RowSpan = rowSpanNum;
                        rowSpanNum = 1;
                        break;
                    }
                    if (i == GridView1.Rows.Count - 1)
                    {
                        gvr.Cells[cellNum].RowSpan = rowSpanNum;
                    }
                }
            }
        }
    隐藏gridView里面最后一行绑定的linkbutton按钮
    
    /// <summary> 
        /// 去掉gridview最后一行的button
        /// </summary> 
        /// <param name="GridView1">GridView</param> 
        /// <param name="cellNum">第几列</param> 
        public static void CoverRow(GridView GridView1)
        {
            int i = 0;
            int count = GridView1.Rows.Count;
            GridViewRow gvr = GridView1.Rows[count - 1];
            //数据生成
            LinkButton S1 = (LinkButton)gvr.FindControl("LinkButton6");
            LinkButton S2 = (LinkButton)gvr.FindControl("LinkButton7");
            LinkButton S3 = (LinkButton)gvr.FindControl("LinkButton8");
            LinkButton S4 = (LinkButton)gvr.FindControl("LinkButton9");
            LinkButton S5 = (LinkButton)gvr.FindControl("LinkButton10");
            LinkButton S6 = (LinkButton)gvr.FindControl("LinkButton11");
     
            S1.Visible = false;
            S2.Visible = false;
            S3.Visible = false;
            S4.Visible = false;
            S5.Visible = false;
            S6.Visible = false;
            
            
        }
    View Code
     


    主要是用到GridView的 GridViewRow这个属性

  • 相关阅读:
    vim讲解
    tar常用解包
    linux扩展权限
    为Virtualbox中的Solaris10安装VBoxAdditions
    Solaris10下Telnet、SSH、ftp使用root登录
    linux软链接和硬链接
    curl命令学习(转载的)
    linux磁盘分区fdisk命令详解
    在服务器上排除问题的头五分钟
    Java对文件压缩/加密/解密/解压缩的例子,DES/RSA
  • 原文地址:https://www.cnblogs.com/zlqblog/p/4432139.html
Copyright © 2020-2023  润新知