Dynamically putting Dropdownlist on web page

E

Ed West

hello,

in the page_load event on a code behind page, i would like to
dynamically put a dropdownlist on the page, and making the name of it
dynamic as well. I tried this but it didn't work... any ideas??


private void Page_Load(object sender, System.EventArgs e)
{
DropDownList ddl = new DropDownList();
ddl.ID = "state";
ddl.Items.Add("1");
ddl.Items.Add("2");
ddl.Items.Add("3");
Page.Controls.Add(ddl);
}


thanks

-dan
 
C

Curt_C [MVP]

doesn't know where to add it first off. use a PlaceHolder to plop it into.
 

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

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top