ASCX User Control Drop Down List Issues

Discussion in 'ASP .Net' started by runtoofar@gmail.com, Oct 19, 2005.

  1. Guest

    I have an ASCX user control with a drop down list inside an ASPX (C#)
    page. The user selects an item from the DDL, clicks a button, and the
    DDL.SelectedValue is supposed to be sent to another function. However,
    the SelectedValue is always the first value in the DDL. I have tried
    several methods to work around this including the examples at:

    http://www.mastercsharp.com/article.aspx?ArticleID=67&&TopicID=2
    http://odetocode.com/Articles/116.aspx

    Everytime however no matter what method is used, I cannot get the true
    SelectedValue of the drop down list.

    All the functions required are inside the ASCX page, there is nothing
    needing to be called in the parent ASPX or C# code-behind.

    Any ideas?! Thanks in advance!
     
    , Oct 19, 2005
    #1
    1. Advertising

  2. Have you checked If the databinding happening in all postbacks?
    The code in Page_load of control should be like below

    if(!Page.IsPostBack())
    {
    yourDDl.datasource =something;
    yourDDl.DataBind();
    }

    "" wrote:

    > I have an ASCX user control with a drop down list inside an ASPX (C#)
    > page. The user selects an item from the DDL, clicks a button, and the
    > DDL.SelectedValue is supposed to be sent to another function. However,
    > the SelectedValue is always the first value in the DDL. I have tried
    > several methods to work around this including the examples at:
    >
    > http://www.mastercsharp.com/article.aspx?ArticleID=67&&TopicID=2
    > http://odetocode.com/Articles/116.aspx
    >
    > Everytime however no matter what method is used, I cannot get the true
    > SelectedValue of the drop down list.
    >
    > All the functions required are inside the ASCX page, there is nothing
    > needing to be called in the parent ASPX or C# code-behind.
    >
    > Any ideas?! Thanks in advance!
    >
    >
     
    =?Utf-8?B?U3JlZWppdGggUmFt?=, Oct 19, 2005
    #2
    1. Advertising

  3. Guest

    Thanks, I knew it was something simple. Too bad I wasted many hours on
    a complex solution not needed!
     
    , Oct 19, 2005
    #3
  4. Scott Allen Guest

    Do you have an event handler for the drop down list's SelectionChanged
    event? That would be an ideal spot to pick up the new value - I'm not
    sure how data binding will help.

    --
    Scott
    http://www.OdeToCode.com/blogs/scott/

    On 19 Oct 2005 11:01:18 -0700, ""
    <> wrote:

    >Thanks, I knew it was something simple. Too bad I wasted many hours on
    >a complex solution not needed!
     
    Scott Allen, Oct 20, 2005
    #4
  5. Elanchezhian

    Joined:
    Aug 8, 2011
    Messages:
    1
    Thanks

    Thanks for your nice tips
     
    Elanchezhian, Aug 8, 2011
    #5
  6. hashing

    Joined:
    Oct 20, 2011
    Messages:
    1
    Thank you! had the same problem and it WAS the postback in the page load event that caused the problem.
    Thanks again!!
     
    hashing, Oct 20, 2011
    #6
    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. SirPoonga
    Replies:
    2
    Views:
    799
    Ben Strackany
    Jan 7, 2005
  2. weiwei
    Replies:
    0
    Views:
    1,047
    weiwei
    Jan 5, 2007
  3. msimmons
    Replies:
    0
    Views:
    514
    msimmons
    Jul 16, 2009
  4. Replies:
    5
    Views:
    295
  5. Replies:
    3
    Views:
    312
Loading...

Share This Page