I want to show Merge header of grid view using C#+ASP.net as shown in my image bellow:
Any idea how to achieve this?
您可以使用网格视图的 Row_Created 事件。您可以在其中设置 Grid 视图的 ColSpan 和 Row Span 属性
请参阅以下示例代码:
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 = "Employee Information";
HeaderCell.ColumnSpan = 3;
HeaderGridRow.Cells.Add(HeaderCell);
HeaderCell = new TableCell();
HeaderCell.Text = "Joining Date";
HeaderCell.ColumnSpan = 2;
HeaderGridRow.Cells.Add(HeaderCell);
grvMergeHeader.Controls[0].Controls.AddAt(0, HeaderGridRow);
}
}
有关更多参考,请参见下面的链接合并网格视图标题here