Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Dynamic HttpTableRow not rendering cell content...

Reply
Thread Tools

Dynamic HttpTableRow not rendering cell content...

 
 
David Whitney
Guest
Posts: n/a
 
      07-17-2003
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.
 
Reply With Quote
 
 
 
 
Louis Dascoulias
Guest
Posts: n/a
 
      07-17-2003
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" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) 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.



 
Reply With Quote
 
 
 
 
David Whitney
Guest
Posts: n/a
 
      07-17-2003
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" <(E-Mail Removed)> wrote in message news:<(E-Mail Removed)>...
> 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" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed) 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.

 
Reply With Quote
 
Louis Dascoulias
Guest
Posts: n/a
 
      07-17-2003
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" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) 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" <(E-Mail Removed)> wrote in message

news:<(E-Mail Removed)>...
> > 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" <(E-Mail Removed)> wrote in message
> > news:(E-Mail Removed) 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.



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
cell's offsetHeight not equal to cell's height?? firefox & IE laszlokenez@gmail.com Javascript 2 08-05-2008 10:44 PM
IE6 SP1 rendering vs IE6 SP2 rendering Peter Mount HTML 4 01-31-2006 08:01 AM
Cell rendering in a JTable asd@asd.com Java 1 05-09-2004 04:54 AM
Cell rendering in a JTable asd@asd.com Java 0 05-03-2004 07:55 PM
JList cell rendering very slow Abs Java 1 01-01-2004 06:17 PM



Advertisments