Search This Blog

Wednesday, September 1, 2010

Merge GridView Cells

Place the following code, or some variation thereof depending on your requirements,
in the RowBinding event of your GridView:

if(e.Row.DataItemIndex%2=0)
{
e.Row.Cells[0].RowSpan = 2;
e.Row.Cells[1].RowSpan = 2;
}

'Remove the extra cells created due to row span for odd rows
if(e.Row.DataItemIndex %2=1)
{
e.Row.Cells.RemoveAt[0];
e.Row.Cells.RemoveAt[0];
e.Row.Cells[1].HorizontalAlign = HorizontalAlign.Center;
}

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.