generating textboxes on the fly ASP.Net (2003)

G

genc_ymeri

Hello over there,
I would like to generate the textboxes on the fly depending on the number of
coulmns in a returning dataset.

I tried something like this :
TextBox temp = new TextBox();
MyPage.Controls.Add(temp);
// <-- the above on failed saying I should specify [run at server] when this
is already a server comp

Another problem I see is that how can I specify where in the form they
should be displayed ??


Any tip will be very much appreciated,
Thank you in advace,

Genc Ymeri.
 
E

Eliyahu Goldin

Genc,

What are you trying to achieve? There must be a better way than adding
controls on the fly.

Eliyahu
 
C

CaffieneRush

Add a Panel or PlaceHolder to your page and add the dynamically created
control to the panel or placeholder.

Ie. Suppose a placeholder called pl1 has already been declaratively
added to your aspx page at design time.

Then:
TextBox temp = new TextBox();
pl1.Controls.Add(temp);

And the answer to the question of adding controls at runtime is that we
do not always know at compile time what to controls to display - e.g.
we could display two buttons (Ok, Cancel) to solicit a response from
the user or a just display label depending on the error that was
encountered.

Andy.
 
J

JDP@Work

I create a general datagrid that has the maximum number of columns and set the
column header text at runtime as well as the visiblity of the columns that I
use.

I put one of a few different kinds of these datagrids on one page each w/in a
panel. I then populate the dg and set the panel's visibility.

HTH

JeffP....
 

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,766
Messages
2,569,569
Members
45,043
Latest member
CannalabsCBDReview

Latest Threads

Top