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/archiv...0/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("Creatin g 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?