zoukankan      html  css  js  c++  java
  • GridView跨行

            string logo = "";
            int i = 0;
            int j = 0;
            protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
            {
                //if(e.Row.RowType==DataControlRowType.Header)
                //{
                //    e.Row.Cells[1].ColumnSpan = 2;
                //    e.Row.Cells[2].Visible = false;
                //    return;
                //}
                if (e.Row.RowType == DataControlRowType.DataRow)
                {
                    if (i == 0)
                    {
                        logo = e.Row.Cells[1].Text;
                        i++;
                    }
                    else
                    {
                        if (logo == e.Row.Cells[1].Text)//如果这一行与上一行的相等
                        {
                            j++;
                        }
                        else
                        {
                            this.GridView1.Rows[i - 1 - j].Cells[1].RowSpan = j + 1;
                            for (int x = j; x > 0; x--)
                            {
                                this.GridView1.Rows[i - x].Cells[1].Visible = false;
                            }

                            j = 0;
                            logo = e.Row.Cells[1].Text;
                        }
                        i++;
                    }           

                }
                if (e.Row.RowType == DataControlRowType.Footer)
                {
                    this.GridView1.Rows[i - 1 - j].Cells[1].RowSpan = j + 1;
                    for (int x = j; x > 0; x--)
                    {
                        this.GridView1.Rows[i - x].Cells[1].Visible = false;
                    }

                    j = 0;
                    logo = e.Row.Cells[1].Text;
                }
            }

  • 相关阅读:
    【剑指Offer】面试招聘题目2:重建二叉树
    简单的安装部署django程序
    Plinga接入
    游戏设计的一些观点
    开方实现
    Mongodb笔记
    动态编程
    数学基础的算法分析
    简单的统计代码程序
    远程在手机上调试android程序
  • 原文地址:https://www.cnblogs.com/yidianfeng/p/1405490.html
Copyright © 2011-2022 走看看