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);Figured it out.
tcCell.Controls.Add( ...)
"George Durzi" <gdurzi@.hotmail.com> wrote in message
news:#tWpeZ8oDHA.2456@.TK2MSFTNGP09.phx.gbl...
> 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,
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" <gdurzi@.hotmail.com> wrote in message
news:%23tWpeZ8oDHA.2456@.TK2MSFTNGP09.phx.gbl...
> 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);
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment