473,395 Members | 1,558 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,395 software developers and data experts.

questions about Controls.add

Bob
Hi,

In aspx file, i have a table:
<asp:Table ID="table1" runat="server">
</asp:Table>

In the code-behind, i create rows and cells:
For i = 0 To 50
r = New TableRow()
for j = 0 To 20
c(i, j) = New TableCell()
r.Cells.Add(c(i, j))
Next
Table1.Rows.Add(r)
Next
....

With this, the table is rendered perfectly (data are displayed in all rows
and cells).

Now i added this line just after 'r.Cells.Add(c(i, j))':
Controls.Add(c(i, j))

Now i have no table anymore: data are dispayed the one after the other in
the page.

My questions are:
1) where is my table, why is is gone?
2) what's the difference between 'Controls.Add(c(i,j))' and
r.Cells.Add(c(i, j)) in this case?

Thanks for help
Bob
Jun 16 '06 #1
2 1071
In one case you are adding row and cell objects to a table. So it
appropriately renders them

In the other case you are adding them to the page - not to the table. So
the page ends up with these objects, which it just renders in the order they
were added. Unlike the table which actually knows how to deal with these,
the page just sort of throws them on one after the other.

It's the difference between adding an object to a Panel you have on your
page, or to the page itself. They are different containers for your objects.

"Bob" <sd*@sdvsd.dc> wrote in message
news:OP**************@TK2MSFTNGP04.phx.gbl...
Hi,

In aspx file, i have a table:
<asp:Table ID="table1" runat="server">
</asp:Table>

In the code-behind, i create rows and cells:
For i = 0 To 50
r = New TableRow()
for j = 0 To 20
c(i, j) = New TableCell()
r.Cells.Add(c(i, j))
Next
Table1.Rows.Add(r)
Next
...

With this, the table is rendered perfectly (data are displayed in all rows
and cells).

Now i added this line just after 'r.Cells.Add(c(i, j))':
Controls.Add(c(i, j))

Now i have no table anymore: data are dispayed the one after the other in
the page.

My questions are:
1) where is my table, why is is gone?
2) what's the difference between 'Controls.Add(c(i,j))' and
r.Cells.Add(c(i, j)) in this case?

Thanks for help
Bob

Jun 16 '06 #2
Bob
Thanks for your explanation.
I have just sent another problem, related with this, but first i had to know
this answer.
"Marina Levit [MVP]" <so*****@nospam.com> wrote in message
news:%2****************@TK2MSFTNGP05.phx.gbl...
In one case you are adding row and cell objects to a table. So it
appropriately renders them

In the other case you are adding them to the page - not to the table. So
the page ends up with these objects, which it just renders in the order they were added. Unlike the table which actually knows how to deal with these,
the page just sort of throws them on one after the other.

It's the difference between adding an object to a Panel you have on your
page, or to the page itself. They are different containers for your objects.
"Bob" <sd*@sdvsd.dc> wrote in message
news:OP**************@TK2MSFTNGP04.phx.gbl...
Hi,

In aspx file, i have a table:
<asp:Table ID="table1" runat="server">
</asp:Table>

In the code-behind, i create rows and cells:
For i = 0 To 50
r = New TableRow()
for j = 0 To 20
c(i, j) = New TableCell()
r.Cells.Add(c(i, j))
Next
Table1.Rows.Add(r)
Next
...

With this, the table is rendered perfectly (data are displayed in all rows and cells).

Now i added this line just after 'r.Cells.Add(c(i, j))':
Controls.Add(c(i, j))

Now i have no table anymore: data are dispayed the one after the other in the page.

My questions are:
1) where is my table, why is is gone?
2) what's the difference between 'Controls.Add(c(i,j))' and
r.Cells.Add(c(i, j)) in this case?

Thanks for help
Bob


Jun 16 '06 #3

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

Similar topics

3
by: Tom Bean | last post by:
I am using Dotfuscator Community Edition to obfuscate an application for Pocket PC written in C#. When I made the first pass with Dotfuscator, the app threw a MissingManifestResourceException. Of...
0
by: Henry | last post by:
Using ideas provided by some of you I was able to figure out how to get the names of the parameters fields of a crystal report specified at run time. The code below just basically puts the...
10
by: neo | last post by:
hi, I am studying ASP.NET and have few questions - 1) The session ID and values of controls is stored in VIEWSTATE variable. So now when we put EnableViewState="false" in Page directive and...
1
by: Sky | last post by:
Although I've been using C# for the last month or so, and accepting out of blind faith the ViewState, I do have some nagging questions about it... can you help verify the following statements? ...
1
by: TBK | last post by:
I'm trying to finish up an assignment I had for a class and basically I'm stuck. The program is supposed to take information you've entered, put it into an array, display it in a listbox and then...
14
by: Kevin | last post by:
A couple of easy questions here hopefully. I've been working on two different database projects which make use of multiple forms. 1. Where's the best/recommended placement for command buttons...
6
by: Kevin | last post by:
I come up with these questions during the day, do some research, and then look for experienced users' input. 1. In Access, we already know it's pretty much an automatic save if you enter data. ...
13
by: M.Siler | last post by:
Let me clarify from my last post. I am not using these 4 questions as the sole screening method. Currently in, the Tampa Bay area (Florida) there is an extreme shortage of C# developers. We have...
2
by: Seguros Catatumbo | last post by:
Hi, i have decent experience with asp 3.0 (classic), and downloaded web developer express to see what's the fuzz over it. I have lots of questions, mostly regarding the use of forms and database...
2
by: Rune Jacobsen | last post by:
Hi all, I have a few questions on deriving from ScrollableControl that I hope will be relatively easy to answer. I am using Visual Studio 2003, C# and ..Net 1.1. I have this custom control I...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.