The Incredible Disappearing Table Row

Discussion in 'ASP .Net' started by Pathogenix@gmail.com, May 6, 2005.

  1. Guest

    Greetings,

    I needed a GridView with an optional extra row in the THEAD and TFOOT.
    I extended GridView and used Dino Esposito's CreateRow overload
    [http://weblogs.asp.net/despos/archive/2004/11/30/272147.aspx] then
    added a new template for the header.

    I overrode CreateChildControls like this

    protected override void CreateChildControls ()
    {
    base.CreateChildControls();

    if (TableHeader != null)
    {

    // childtable
    Table t = (Table)Controls[0];
    GridViewRow row = CreateRow( -1, -1, DataControlRowType.Header,
    DataControlRowState.Normal);


    System.Web.HttpContext.Current.Trace.Warn("Creating children");


    TemplateContainer c = new TemplateContainer(this);

    TableHeaderCell cell = new TableHeaderCell();
    cell.ColumnSpan = this.Columns.Count;
    TableHeader.InstantiateIn(c);
    cell.Controls.Add(c);
    row.Cells.Add(cell);

    row.CssClass = "mainhead";
    t.Rows.AddAt(0, row);

    LiteralControl l =
    (LiteralControl)t.Rows[0].Cells[0].Controls[0].Controls[0];
    System.Web.HttpContext.Current.Trace.Warn(l.Text);
    }
    }

    This works on the first request, but the table row disappears
    onpostback.
    After much tearing of hair, I found out that the control existed until
    GridView.OnPreRender was called.

    Does anyone have any idea why OnPreRender would eat my table row?
     
    , May 6, 2005
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.

Share This Page