David,
It finally occured to me: you must assign an ID to the child control.
Nothing will automatically assign one to the control.
Previous thoughts:
You may need to call EnsureChildControls at some point after adding
the textboxes to the cell since the textboxes aren't a component/property
of the cells.
I played around with createing 'table-maker' controls in VB.Net a while back
so I can provide some code if needed..
Louis Dascoulias, AWS
"David Whitney" <> wrote in message
news: om...
> The short answer is no, I didn't, but here's why I didn't...
>
> I presumed, probably incorrectly, that each element still knows how to
> render itself, and that rendering a table row would be a matter of
> rendering a cell, then its contents, etc, then the next cell, its
> contents, etc... which would be part of its default behavior.
>
> The code is essentially like this - note this is just scratched out
> from memory - I'm away from my source at the moment.
>
> public void MyDerivedHtmlTableRow(string somevalue)
> {
> HtmlTableCell hc = new HtmlTableCell();
> HtmlInputBox ib = new HtmlInputBox();
> ib.Text=somevalue;
>
> hc.Controls.Add(ib);
>
> //... add two other cells/controls similarly
>
> this.Cells.Add(hc);
> }
>
> The calling class - a control - uses it like this:
>
> public void AddTableRow()
> {
> for (x=1;x<=10;x++)
> table.Rows.AddAt(number,
> new MyDerivedTableRow(System.Convert.ToString(x))));
> }
>
> Since the *rows* rendered, but just not their contents, it seemed I
> didn't need to implement custom rendering; the controls on each table
> cell were not being rendered. If I'm just missing the boat on where to
> do some rendering overrides, that's cool, I'm just trying to figure
> out the right place...and a bit of where I might be confused..or is it
> something as simple as
>
> protected override void Render(HtmlTextWriter writer)
> {
> writer.Write(<TR>);
> //custom render the first cell, and its one child control??
> //custom render the second cell??
> writer.Write(</TR>);
>
> //or
>
> //call an existing rendering method on the cell and its child
> control??
> }
>
> Thoughts? (And thanks for your help, too!)
>
> -David
>
>
>
> "Louis Dascoulias" <> wrote in message
news:<>...
> > David,
> > Did you override the render method in the class that derives from
> > HtmlTableRow? Something like this:
> > protected override void Render(HtmlTextWriter writer)
> > {
> > writer.Write(this.Text);
> > }
> >
> > You didn't provide any code so I'm asking the obvious.
> >
> > Louis Dascoulias, AWS
> >
> > "David Whitney" <> wrote in message
> > news: om...
> > > All:
> > >
> > > I have a control that renders a table. As the table is rendered, each
> > > row in the table is constructed by creating a run-time (dynamic)
> > > object that is derived from an HtmlTableRow. The row has three
> > > HtmlTableCell objects, and each cell contains a single control added
> > > to the HtmlTableCell's Controls collection. The basic table renders
> > > correctly, but the controls within the HtmlTableCell objects do not;
> > > the cells are just empty. (Just <TD></TD> tags).
> > >
> > > I add the controls to each cell in my derived class constructor, and
> > > that code fires in the debugger. The controls just don't render.
> > >
> > > I'm sure there is a very basic problem I'm overlooking, but I'm
> > > stymied as to what it is.
> > >
> > > I'd greatly appreciate any thoughts.
> > >
> > > David
> > >
> > > ps Please reply to group; email in message is long since dead.
|