473,385 Members | 1,373 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Problems displaying HtmlTable on page

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[i].ItemArray[j])));
r.Cells.Add(c);
}
t1.Rows.Add(r);

}

t1.Visible = true;


--
Al
Nov 19 '05 #1
2 1128
It looks like you've forgotten this important line:

Page.Controls.Add(t1);

--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://SteveOrr.net

"Al Wilkerson" <ac***@comcast.net> wrote in message
news:kN********************@comcast.com...
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[i].ItemArray[j])));
r.Cells.Add(c);
}
t1.Rows.Add(r);

}

t1.Visible = true;


--
Al

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

Al
"Al Wilkerson" <ac***@comcast.net> wrote in message
news:kN********************@comcast.com...
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[i].ItemArray[j])));
r.Cells.Add(c);
}
t1.Rows.Add(r);

}

t1.Visible = true;


--
Al

Nov 19 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Ajay Desh | last post by:
Hi I am gettin error, if i try to find the top position of a table. Here is what i am doing.I have a HtmlTable (Table3 is the name/id) created.It has a position and a Top and Left co-ordinates...
2
by: Michael Meckelein | last post by:
Hi all! I have a table like Table myTable = new Table(); Now, I want to publish the table as part of a webpage and as part of a word document. I tried to convert the table, but the compiler...
2
by: Jay | last post by:
I have been trying to link and HTML Table to a Code behind variable. I have seen people saying that they can do this but I cannot get it to work. What am i missing? In the HTML Code I have:...
1
by: Leo | last post by:
I created a user control which is some text contained in a HtmlTable. I put this control into main form. I would like to have the ability to move this control around in the main form. I think one...
3
by: Al Wilkerson | last post by:
Hey, I have a Web Form with a drop down list, textbox, and search button. When click the search button an SQL server database is queried fordata. Once I have the data in a dataset I use the...
1
by: Al Wilkerson | last post by:
Hey, I have a Web Form with a drop down list, textbox, and search button. When click the search button an SQL server database is queried fordata. Once I have the data in a dataset I use the...
1
by: TRobran | last post by:
What I'm trying to do seems pretty straightforward so I must be missing something simple. Any help is greatly appreciated. On my page I have a DropDownList, a HtmlTable and a Button. Each row...
4
by: Tim::.. | last post by:
Can someone please help.... I'm having major issues with a user control I'm tring to create! I an trying to execute a sub called UploadData() from a user control which I managed to do but for...
2
by: Scott McNair | last post by:
Hi all, I have a page that displays an order confirmation to the end-user whenever he places an order. On that order is a table generated using System.Web.UI.HtmlControls.HtmlTable. My company...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.