PDA

Click to See Complete Forum and Search --> : Dynamic Control creation?


Fishcake
Sep 11th, 2003, 08:50 AM
Hi,

I'm pretty new to asp.net and kind of been thrown in at the deepend.

I'd like to know if it's possible to dynamically create webform controls at run time? In this case a user enters a number and that number of dropdownlists are created on the page.

Any help appreciated.

Lethal
Sep 11th, 2003, 09:04 AM
Sure, anything is possible with asp.net


private void Button1_Click(object sender, System.EventArgs e) {
for(int i = 0; i < int.Parse(TextBox1.Text); i++) {
this.FindControl("Form1").Controls.Add(new DropDownList());
}
}
;)

Fishcake
Sep 11th, 2003, 10:32 AM
Thanks a lot for your reply. Got it working ok. Turns out now that there will be in the region of 100-120 drop down boxes so now just to make sure they're all laid out nicely :)