Home All Groups Group Topic Archive Search About

generating textboxes on the fly ASP.Net (2003)

Author
8 Mar 2006 10:36 PM
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.

Author
9 Mar 2006 8:22 AM
Eliyahu Goldin
Genc,

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

Eliyahu

Show quoteHide quote
"genc_ymeri" <genc_ym***@hotmail.com> wrote in message
news:Y9ydnc5yy6zOx5LZRVn-tA@adelphia.com...
> 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.
>
Author
9 Mar 2006 10:44 AM
CaffieneRush@gmail.com
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.
Author
14 Mar 2006 7:04 AM
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....

<CaffieneR***@gmail.com> wrote in message
Show quoteHide quote
news:1141901041.778228.233330@z34g2000cwc.googlegroups.com...
> 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.
>