Thursday 29 March 2018

Merge Gridview Rows with same values in cells using Asp.net and C#

///////////////

   protected void GV_PerformanceObjective_RowDataBound(object sender, GridViewRowEventArgs e)
    {

        for (int i = GV_PerformanceObjective.Rows.Count - 2; i >= 0; i--)
        {
            GridViewRow row = GV_PerformanceObjective.Rows[i];
            GridViewRow preRow = GV_PerformanceObjective.Rows[i + 1];

            string currRow = ((LinkButton)row.FindControl("lbtn_EditObjective")).Text.Trim();
            string prevRow = ((LinkButton)preRow.FindControl("lbtn_EditObjective")).Text.Trim();

            if (currRow == prevRow)
            {
                row.Cells[0].RowSpan = preRow.Cells[0].RowSpan < 2 ? 2 : preRow.Cells[0].RowSpan + 1;
                preRow.Cells[0].Visible = false;
            }
        }

    }




No comments:

Post a Comment

Excel Sort values in ascending order using function TEXTJOIN

 Excel ::  Text ::  1,3,5,2,9,5,11 Result :: 1,2,3,5,5,9,11 Formula ::     TEXTJOIN ( ",",1,SORT(MID(SUBSTITUTE( A1 ,","...