user control with a dropdown

Discussion in 'ASP .Net' started by mkarbarz@gmail.com, Nov 29, 2006.

  1. Guest

    Hi,

    I have a user control that contains a dropdownlist. I populate the
    list in page load event of the user control in the following manner:

    if (!IsPostBack) {
    _ddUserCity.DataSourceID = "SqlDataSource1";
    _ddUserCity.DataTextField = "user_city";
    _ddUserCity.DataValueField = "user_city";
    _ddUserCity.DataBind();
    }

    The problem is with the selected index property. The list always
    selects the first element on pageload even if it's a postback .
    Dropdownlist is autopostback enabled and has view state enabled. I
    cannot for the life of me figure out why the selected index is not
    being preserved on page postback.

    Any help would be appreciated.

    Thanks
     
    , Nov 29, 2006
    #1
    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. vishnu
    Replies:
    1
    Views:
    1,238
    Patrick.O.Ige
    Mar 25, 2006
  2. Mad Scientist Jr
    Replies:
    0
    Views:
    665
    Mad Scientist Jr
    Mar 22, 2006
  3. Mike
    Replies:
    1
    Views:
    843
  4. acadam
    Replies:
    0
    Views:
    776
    acadam
    Dec 27, 2006
  5. Jonathan Wood

    User Control to Control Other User Control

    Jonathan Wood, Jan 24, 2010, in forum: ASP .Net
    Replies:
    4
    Views:
    572
    Jonathan Wood
    Feb 2, 2010
Loading...

Share This Page