Wednesday, 2 April 2014

Gridview Sub Header

Grid View Sub Header:
 
protected void grvMergeHeader_RowCreated(object sender, GridViewRowEventArgs e)
{
 if (e.Row.RowType == DataControlRowType.Header) {
  GridView HeaderGrid = (GridView)sender;
  GridViewRow HeaderGridRow = new GridViewRow(0, 0, DataControlRowType.Header, DataControlRowState.Insert);
  TableCell HeaderCell = new TableCell();
  HeaderCell.Text = "Department";
  HeaderCell.ColumnSpan = 2;
  HeaderGridRow.Cells.Add(HeaderCell);

  HeaderCell = new TableCell();
  HeaderCell.Text = "Employee";
  HeaderCell.ColumnSpan = 2;
  HeaderGridRow.Cells.Add(HeaderCell);


  grvMergeHeader.Controls(0).Controls.AddAt(0, HeaderGridRow);
 }
}

No comments:

Post a Comment