0

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 にレコードがない場合でも、ヘッダーをマージするにはどうすればよいですか?

4

1 に答える 1

0

コードをOnRowCreatedイベントからLoadイベントに移動しますWindow/Control/Page

于 2013-01-09T05:34:36.580 に答える