Problems displaying HtmlTable on page

A

Al Wilkerson

Hey,

Below is some code to generate an HtmlTable dynamically, however the table
does not show on page.
When tracing through, the values from the database come out correctly, but
the table never displays.
Can anyone see anything that could possibly be the reason ?
Thanks,


t1 = new HtmlTable();

int maxrows = 0;
int maxcolumns = 0;
maxrows = ds.Tables["Products"].Rows.Count;
maxcolumns = ds.Tables["Products"].Columns.Count;

int row = 0;

for( int i = 0; i < maxrows - 1; i++)
{
HtmlTableRow r = new HtmlTableRow();
row = row + 1;

for( int j = 0; j < maxcolumns - 1; j++)
{
HtmlTableCell c = new HtmlTableCell();

c.Controls.Add(new
LiteralControl(Convert.ToString(ds.Tables["Products"].Rows.ItemArray[j])));
r.Cells.Add(c);
}
t1.Rows.Add(r);

}

t1.Visible = true;
 
S

Steve C. Orr [MVP, MCSD]

It looks like you've forgotten this important line:

Page.Controls.Add(t1);
 
A

Al Wilkerson

Someone mentioned that I forgot to add "Page.Controls.Add(t1)", but that
didn't work either.

Al
 

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,770
Messages
2,569,584
Members
45,077
Latest member
SangMoor21

Latest Threads

Top