How to use Rowspan in Gridview for 1st Column only

前端 未结 3 1975
遥遥无期
遥遥无期 2020-12-17 20:47

Need help to resolve a issue related with Gridview layout. I am trying to implement custome Gridview with Itemtemplate Columns using C#.Net language and want to include view

3条回答
  •  悲哀的现实
    2020-12-17 21:29

     protected void GridView31_DataBound1(object sender, EventArgs e)
    {
        int i = 1;
        for (int rowIndex = grdView31.Rows.Count - 2; rowIndex >= 0; rowIndex--)
        {
            GridViewRow gvRow = grdView31.Rows[rowIndex];
            GridViewRow gvPreviousRow = grdView31.Rows[rowIndex + 1];
    
            if (i % 4 !=0)
            {
                if (gvPreviousRow.Cells[0].RowSpan < 2)
                {
                    gvRow.Cells[0].RowSpan = 2;
                }
                else
                {
                    gvRow.Cells[0].RowSpan = gvPreviousRow.Cells[0].RowSpan + 1;
                }
                gvPreviousRow.Cells[0].Visible = false;
            }
            i++;
        }
    

    This worked our for me. Trial & error :)

提交回复
热议问题