The Incredible Disappearing Table Row

P

Pathogenix

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?
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,754
Messages
2,569,528
Members
45,000
Latest member
MurrayKeync

Latest Threads

Top