【发布时间】:2015-06-05 12:37:21
【问题描述】:
我有一个 gridView,我想将其前 11 列设置为 Heading like="NMAT APPLICANT DETAILS"。我的网格视图名称是 GridView1。我该如何设置?
我是通过下面提到的方法完成的。现在如何调整这 11 个单元格的标题中心??
我的代码
protected void GridView1_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 = "NMAT APPLICANT DETAILS";
HeaderCell.ColumnSpan = 11;
HeaderGridRow.Cells.Add(HeaderCell);
GridView1.Controls[0].Controls.AddAt(0, HeaderGridRow);
}
}
【问题讨论】:
-
您的意思是要为每一列设置一个标题?
-
@lzzy,不,我只想要一个跨度为 11 的标题
-
“设置前 4 行”是什么意思?你的意思是你想要一个有两个标题的表格,一个是 4 列,另一个是 11 列?
-
@Daniel Cook,请找到我编辑的问题
-
你的问题还是有点混乱。也许你应该用
<h2 align="center">Your Header Text</h2>