Dynamically putting Dropdownlist on web page

Discussion in 'ASP .Net' started by Ed West, Aug 5, 2004.

  1. Ed West

    Ed West Guest

    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
    Ed West, Aug 5, 2004
    #1
    1. Advertising

  2. Ed West

    Curt_C [MVP] Guest

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


    --
    Curt Christianson
    Owner/Lead Developer, DF-Software
    Site: http://www.Darkfalz.com
    Blog: http://blog.Darkfalz.com


    "Ed West" <> wrote in message
    news:...
    > 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
    >
    Curt_C [MVP], Aug 5, 2004
    #2
    1. Advertising

  3. Ed West

    Ed West Guest

    great, thanks.

    Curt_C [MVP] wrote:
    > doesn't know where to add it first off. use a PlaceHolder to plop it into.
    >
    >
    Ed West, Aug 5, 2004
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. BoBo the monkey

    Putting a date in a .ASPX page

    BoBo the monkey, Mar 5, 2004, in forum: ASP .Net
    Replies:
    2
    Views:
    2,391
    Peter Rilling
    Mar 6, 2004
  2. Bishoy George

    putting struct properties into dropdownlist

    Bishoy George, Oct 6, 2005, in forum: ASP .Net
    Replies:
    2
    Views:
    407
    Bishoy George
    Oct 6, 2005
  3. Saurabh
    Replies:
    6
    Views:
    4,521
    Chris Smith
    May 30, 2004
  4. Sunfire
    Replies:
    2
    Views:
    646
    Sunfire
    Nov 5, 2007
  5. MattB
    Replies:
    0
    Views:
    202
    MattB
    Jul 15, 2004
Loading...

Share This Page