TableRow/TableCell Serverside Q

  • Thread starter Thread starter George Durzi
  • Start date Start date
G

George Durzi

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
 
Back
Top