TableRow/TableCell Serverside Q

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);
 
N

Nicole Calinoiu

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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,816
Latest member
SapanaCarpetStudio

Latest Threads

Top