本文介绍了合并GridView标题列合并多个标题ASP.NET的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
protected void GrdLeaveMaster_RowCreated(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.Header)
{
GridView HeaderGrid = (GridView)sender;
GridViewRow HeaderGridRow =
new GridViewRow(2, 2, DataControlRowType.EmptyDataRow,
DataControlRowState.Insert);
TableCell HeaderCell = new TableCell();
HeaderCell.Text = "PaidLeave";
HeaderCell.ColumnSpan = 2;
HeaderGridRow.Cells.Add(HeaderCell);
HeaderCell = new TableCell();
HeaderCell.Text = "accumulated";
HeaderCell.ColumnSpan = 2;
HeaderGridRow.Cells.Add(HeaderCell);
GrdLeaveMaster.Controls[0].Controls.AddAt(0, HeaderGridRow);
}
}
我希望标题不显示在第一列中,而是显示在第二列中
I want header does not show in first column it shows on second column
推荐答案
TableCell HeaderCell = new TableCell();
HeaderCell.Text = "";
HeaderCell.ColumnSpan = 1;
HeaderGridRow.Cells.Add(HeaderCell);
TableCell HeaderCell = new TableCell();
HeaderCell.Text = "PaidLeave";
HeaderCell.ColumnSpan = 1;
HeaderGridRow.Cells.Add(HeaderCell);
希望对您有帮助
这篇关于合并GridView标题列合并多个标题ASP.NET的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!