Wednesday, January 9, 2019

Merge Gridview Cell

 <asp:GridView ID="GridView2" runat="server" AutoGenerateColumns="False"
                       
Width="696px" OnDataBound="OnDataBound">


  protected void OnDataBound(object sender, EventArgs e)
    {
        for (int i = GridView2.Rows.Count - 1; i > 0; i--)
        {
            GridViewRow row = GridView2.Rows[i];
            GridViewRow previousRow = GridView2.Rows[i - 1];
            if (row.Cells[0].Text == previousRow.Cells[0].Text)
            {
                if (previousRow.Cells[0].RowSpan == 0)
                {
                    if (row.Cells[0].RowSpan == 0)
                    {
                        previousRow.Cells[0].RowSpan += 2;
                    }
                    else
                    {
                        previousRow.Cells[0].RowSpan = row.Cells[0].RowSpan + 1;
                    }
                    row.Cells[0].Visible = false;
                }
            }

        }
    }

1 comment:

  1. Thanks for sharing such useful information with us. I hope you will share some more info about your blog. Please Keep sharing.
    Best Reasons to Choose AngularJS Development in 2022

    ReplyDelete

ADVANCE 2025

 HTML TABLE SCROLL BAR  <style>      .table-container {             width: 100%;             overflow-x: auto; /* Enables horizontal s...