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);
}
}
我希望标题不显示在第二列
中显示的第一列中
答案 0 :(得分:3)
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);
希望有所帮助