Gridview で問題が発生しました。Gridview にレコードがない場合はヘッダーをマージできませんが、Gridview にレコードが含まれている場合はヘッダーがマージされます。
Gridview でヘッダーをマージするために使用したコードは次のとおりです。
protected void grdWorkExperience_RowCreated(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.Header)
{
GridView oGridView = (GridView)sender;
GridViewRow oGridViewRow = new GridViewRow(0, 0, DataControlRowType.Header, DataControlRowState.Insert);
TableCell oTableCell = new TableCell();
oTableCell.Text = string.Empty;
oTableCell.ColumnSpan = 2;
oTableCell.BorderColor = System.Drawing.Color.White;
oGridViewRow.Cells.Add(oTableCell);
oTableCell = new TableCell();
oTableCell.Text = "Inclusive Dates(mm/dd/yyyy)";
oTableCell.ColumnSpan = 2;
oTableCell.Font.Bold = true;
oTableCell.Font.Size = 9;
oTableCell.Font.Name = "Verdana";
oTableCell.HorizontalAlign = HorizontalAlign.Center;
oTableCell.BackColor = System.Drawing.Color.FromArgb(0x33, 0x66, 0xCC);
oTableCell.ForeColor = System.Drawing.Color.White;
oTableCell.BorderColor = System.Drawing.Color.Gray;
oGridViewRow.Cells.Add(oTableCell);
oTableCell = new TableCell();
oTableCell.BorderColor = System.Drawing.Color.White;
oTableCell.ColumnSpan = 13;
oGridViewRow.Cells.Add(oTableCell);
oGridView.Controls[0].Controls.AddAt(0, oGridViewRow);
}
}
その関数をGridviewのonRowCreatedイベントに配置しました
Gridview にレコードがない場合でも、ヘッダーをマージするにはどうすればよいですか?