Merge Grid Rows of the Specific Column

protected void gvTermExaminerUpdate_DataBound(object sender, EventArgs e)
{
for (int rowIndex = gvTermExaminerUpdate.Rows.Count - 2; rowIndex >= 0; rowIndex--)
{
GridViewRow gvRow = gvTermExaminerUpdate.Rows[rowIndex];
GridViewRow gvPreviousRow = gvTermExaminerUpdate.Rows[rowIndex + 1];
Label PP = (Label)gvRow.FindControl("leblCourseCode");
Label PPP = (Label)gvPreviousRow.FindControl("leblCourseCode");
if (PP.Text == PPP.Text)
{
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;
}
}
}

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s