Dynamic HttpTableRow not rendering cell content...

Ask a Question related to ASP.NET General, Design and Development.

  1. #1

    Default Dynamic HttpTableRow not rendering cell content...

    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.
    David Whitney Guest

  2. Similar Questions and Discussions

    1. Dynamic content and page rendering
      Hi there, got a bit of a problem that's not easy to explain. I've got a site written in classic .asp, with bits and bobs of JavaScript, including...
    2. possible to target dynamic content to a table cell?
      I'm in proof of concept mode. I've set up a small table with two rows and two columns. Column 1 shows a thumbnail image in each cell. Column 2...
    3. Cell Rendering with click event
      I have a data grid that is a component for another page. In one of the columns in the data grid I am providing a check box. The plan is for the...
    4. Cell Rendering / Change Text
      I have a data grid that is using cellrendering in on of the columns to provide a check box. When I check the box I would like to be able to change...
    5. Rendering design-time content on a web UserControl
      I created a web user control and would like to add the ability for it to contain design-time rendering capabilities. So that, during development,...
  3. #2

    Default Re: Dynamic HttpTableRow not rendering cell content...

    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" <intrepid_dw@hotmail.com> wrote in message
    news:63563b00.0307170356.7e1ae677@posting.google.c 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.

    Louis Dascoulias Guest

  4. #3

    Default Re: Dynamic HttpTableRow not rendering cell content...

    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" <louisd@automark.net> wrote in message news:<e1BTwtFTDHA.2152@TK2MSFTNGP12.phx.gbl>...
    > 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" <intrepid_dw@hotmail.com> wrote in message
    > news:63563b00.0307170356.7e1ae677@posting.google.c 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.
    David Whitney Guest

  5. #4

    Default Re: Dynamic HttpTableRow not rendering cell content...

    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" <intrepid_dw@hotmail.com> wrote in message
    news:63563b00.0307170959.607d080b@posting.google.c 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" <louisd@automark.net> wrote in message
    news:<e1BTwtFTDHA.2152@TK2MSFTNGP12.phx.gbl>...
    > > 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" <intrepid_dw@hotmail.com> wrote in message
    > > news:63563b00.0307170356.7e1ae677@posting.google.c 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.

    Louis Dascoulias Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139