TableRow/TableCell Serverside Q

Discussion in 'ASP .Net' started by George Durzi, Nov 5, 2003.

  1. George Durzi

    George Durzi Guest

    Consider this pseudo HTML from a web form

    <asp:Table>
    <asp:TableRow>
    <asp:TableCell>
    <asp:Table>
    <asp:TableRow>
    <asp:TableCell></asp:TableCell>
    <asp:TableCell></asp:TableCell>
    </asp:TableRow>
    </asp:Table>
    </asp:TableCell>
    </asp:TableRow>
    </asp:Table>

    How can I construct this on the server side? Assume that I start with an
    empty asp:table control on my webform, as follows:

    <asp:Table ID="tblViewWall" Runat="server"></asp:Table>

    I've done the following:

    TableRow trRow = new TableRow();
    TableCell trCell = new TableCell();
    trRow.Cells.Add(trCell);

    // Now inside trCell, I want to add another table with 1 row, and two
    cells
    // I can't see how I would create another Table, and add it to a
    TableCell

    tblViewWall.Rows.Add(trRow);
     
    George Durzi, Nov 5, 2003
    #1
    1. Advertising

  2. George Durzi

    George Durzi Guest

    Figured it out.
    tcCell.Controls.Add( ...)


    "George Durzi" <> wrote in message
    news:#...
    > Consider this pseudo HTML from a web form
    >
    > <asp:Table>
    > <asp:TableRow>
    > <asp:TableCell>
    > <asp:Table>
    > <asp:TableRow>
    > <asp:TableCell></asp:TableCell>
    > <asp:TableCell></asp:TableCell>
    > </asp:TableRow>
    > </asp:Table>
    > </asp:TableCell>
    > </asp:TableRow>
    > </asp:Table>
    >
    > How can I construct this on the server side? Assume that I start with an
    > empty asp:table control on my webform, as follows:
    >
    > <asp:Table ID="tblViewWall" Runat="server"></asp:Table>
    >
    > I've done the following:
    >
    > TableRow trRow = new TableRow();
    > TableCell trCell = new TableCell();
    > trRow.Cells.Add(trCell);
    >
    > // Now inside trCell, I want to add another table with 1 row, and two
    > cells
    > // I can't see how I would create another Table, and add it to a
    > TableCell
    >
    > tblViewWall.Rows.Add(trRow);
    >
    >
     
    George Durzi, Nov 5, 2003
    #2
    1. Advertising

  3. George,

    Try something like this:

    TableCell newCell = new TableCell();
    Table childTable = new Table();
    newCell.Controls.Add(childTable);

    //Populate the child table here.

    TableRow newRow = new TableRow();
    newRow.Cells.Add(newCell);

    this.tblViewWall.Rows.Add(newRow);


    HTH,
    Nicole

    "George Durzi" <> wrote in message
    news:%...
    > Consider this pseudo HTML from a web form
    >
    > <asp:Table>
    > <asp:TableRow>
    > <asp:TableCell>
    > <asp:Table>
    > <asp:TableRow>
    > <asp:TableCell></asp:TableCell>
    > <asp:TableCell></asp:TableCell>
    > </asp:TableRow>
    > </asp:Table>
    > </asp:TableCell>
    > </asp:TableRow>
    > </asp:Table>
    >
    > How can I construct this on the server side? Assume that I start with an
    > empty asp:table control on my webform, as follows:
    >
    > <asp:Table ID="tblViewWall" Runat="server"></asp:Table>
    >
    > I've done the following:
    >
    > TableRow trRow = new TableRow();
    > TableCell trCell = new TableCell();
    > trRow.Cells.Add(trCell);
    >
    > // Now inside trCell, I want to add another table with 1 row, and two
    > cells
    > // I can't see how I would create another Table, and add it to a
    > TableCell
    >
    > tblViewWall.Rows.Add(trRow);
    >
    >
     
    Nicole Calinoiu, Nov 5, 2003
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. frank
    Replies:
    0
    Views:
    368
    frank
    Jul 11, 2003
  2. Steve - DND

    Click Event for TableRow?

    Steve - DND, Jul 31, 2003, in forum: ASP .Net
    Replies:
    3
    Views:
    535
    Steve - DND
    Jul 31, 2003
  3. Coleen

    Span in an ASP TableRow

    Coleen, Jan 26, 2004, in forum: ASP .Net
    Replies:
    2
    Views:
    473
    coleenholley
    Jan 26, 2004
  4. hb
    Replies:
    6
    Views:
    2,062
    =?Utf-8?B?IkplZmZyZXkgVGFuW01TRlRdIg==?=
    Mar 4, 2004
  5. Brian K. Williams

    TableCell oTableCell = new TableCell(); noWrap?

    Brian K. Williams, Apr 30, 2004, in forum: ASP .Net
    Replies:
    2
    Views:
    2,593
    Brian K. Williams
    Apr 30, 2004
Loading...

Share This Page