Example ScreenShot:
protected void GdvAccountWise_RowCreated(object sender, GridViewRowEventArgs e)In code-behind, on the 'OnRowCreated' event of gridview, write the follwing code:
{
try
{
if (e.Row.RowType == DataControlRowType.Header)
{
#region HeaderRow
GridViewRow HeaderRow = new GridViewRow(0, 0, DataControlRowType.Header, DataControlRowState.Insert);
TableCell HeaderCell = new TableCell();
HeaderCell.Text = "Account";
HeaderCell.ColumnSpan = 2;
HeaderRow.Cells.Add(HeaderCell);
HeaderCell = new TableCell();
HeaderCell.Text = "Date";
HeaderCell.ColumnSpan = 2;
HeaderRow.Cells.Add(HeaderCell);
HeaderCell = new TableCell();
HeaderCell.Text = "Utilization";
HeaderCell.ColumnSpan = 3;
HeaderRow.Cells.Add(HeaderCell);
Gridview1.Controls[0].Controls.AddAt(0, HeaderRow);
GridViewRow HeaderRow1 = new GridViewRow(1, 0, DataControlRowType.Header, DataControlRowState.Insert);
HeaderCell = new TableCell();
HeaderCell.Text = "AccountID";
HeaderRow1.Cells.Add(HeaderCell);
HeaderCell = new TableCell();
HeaderCell.Text = "AccountName";
HeaderRow1.Cells.Add(HeaderCell);
......................
......................
Gridview1.Controls[0].Controls.AddAt(1, HeaderRow1);
#endregion
}
}
catch (Exception ex)
{
//catch exception code;
}
}
Hope this post will be helpful to you.
Do like and Comment if you like the post..!
No comments:
Post a Comment