Lets Have a fun with Technology.

BTemplates.com

Follow by Email

Monday, September 8, 2008

Merge Cell in GridView Header ASP.Net 2.0


Merge Cell in GridView Header ASP.Net 2.0
Here i am going to see one of the best method to do that. To have additional header, we need to add one GridViewRow of header type to GridView inside OnRowCreated event method. The code snippet for doing this,
protected void GridView_Merge_Header_RowCreated(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.Header)
{
//Build custom header.
GridView oGridView = (GridView)sender;
GridViewRow oGridViewRow = new GridViewRow(0, 0, DataControlRowType.Header, DataControlRowState.Insert);
TableCell oTableCell = new TableCell();
//Add Department
oTableCell.Text = "Writen Test Result";
oTableCell.ColumnSpan = 4;
oGridViewRow.Cells.Add(oTableCell);
//Add Employee
oTableCell = new TableCell();
oTableCell.Text = "Verbalk Test Result";
oTableCell.ColumnSpan = 4;
oGridViewRow.Cells.Add(oTableCell);
oGridView.Controls[0].Controls.AddAt(0, oGridViewRow);
}
}


Prev Post                                                      All Post                                                           Next Post



1 comment: