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. Advertisements

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. Tom Rowton
    Replies:
    2
    Views:
    922
    Tom Rowton
    Aug 1, 2003
  2. vatech1993
    Replies:
    4
    Views:
    5,903
    =?Utf-8?B?U8Opcmdpbw==?=
    Dec 11, 2004
  3. Replies:
    0
    Views:
    593
  4. Don
    Replies:
    3
    Views:
    5,701
    Karl Seguin
    Mar 11, 2005
  5. ABC
    Replies:
    1
    Views:
    2,844
    Larry
    Oct 4, 2005
  6. ABC
    Replies:
    0
    Views:
    617
  7. Mad Scientist Jr
    Replies:
    0
    Views:
    892
    Mad Scientist Jr
    Mar 22, 2006
  8. Jonathan Wood

    User Control to Control Other User Control

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