DropDownList Problem

Discussion in 'ASP .Net' started by Lou Civitella, Dec 20, 2006.

  1. I have two drop down list boxes on my asp page. The boxes store a country
    value on my page. They are filled by code during the load event and then I
    set their values in code from a table on a SQL server. If the values are the
    same then all is OK but if the values happen to be different I get this
    error
    Cannot have multiple items selected in a DropDownList.
    I cannot fiugre out why this keeps happening. I have two other DropDownList
    boxes on my page that show state information and they work correctly. I dont
    have any code that sets the country fields to each other so I dont know
    where the problem lies.

    If any one has any suggestions that would be great as this problem is really
    puzzling me.

    Thanks In Advance,
    Lou
    Lou Civitella, Dec 20, 2006
    #1
    1. Advertising

  2. Lou Civitella

    David Wier Guest

    When you populate the dropdownlists in the Page_Load - make sure they're
    surrounded by an if/then Postback block:
    if Not Page.IsPostBack then
    ' populate lists
    end if

    --
    David Wier
    MVP/ASPInsider
    http://aspnet101.com
    http://aspexpress.com



    "Lou Civitella" <> wrote in message
    news:...
    > I have two drop down list boxes on my asp page. The boxes store a country
    > value on my page. They are filled by code during the load event and then I
    > set their values in code from a table on a SQL server. If the values are

    the
    > same then all is OK but if the values happen to be different I get this
    > error
    > Cannot have multiple items selected in a DropDownList.
    > I cannot fiugre out why this keeps happening. I have two other

    DropDownList
    > boxes on my page that show state information and they work correctly. I

    dont
    > have any code that sets the country fields to each other so I dont know
    > where the problem lies.
    >
    > If any one has any suggestions that would be great as this problem is

    really
    > puzzling me.
    >
    > Thanks In Advance,
    > Lou
    >
    >
    David Wier, Dec 20, 2006
    #2
    1. Advertising

  3. This may happen if two ddls share the same item collection. When you make
    an item selected via one ddl, and the item is participating also in another
    ddl, and another ddl already has some other item selected, than you get this
    problem.

    --
    Eliyahu Goldin,
    Software Developer & Consultant
    Microsoft MVP [ASP.NET]
    http://msmvps.com/blogs/egoldin


    "Lou Civitella" <> wrote in message
    news:...
    >I have two drop down list boxes on my asp page. The boxes store a country
    >value on my page. They are filled by code during the load event and then I
    >set their values in code from a table on a SQL server. If the values are
    >the same then all is OK but if the values happen to be different I get this
    >error
    > Cannot have multiple items selected in a DropDownList.
    > I cannot fiugre out why this keeps happening. I have two other
    > DropDownList boxes on my page that show state information and they work
    > correctly. I dont have any code that sets the country fields to each other
    > so I dont know where the problem lies.
    >
    > If any one has any suggestions that would be great as this problem is
    > really puzzling me.
    >
    > Thanks In Advance,
    > Lou
    >
    Eliyahu Goldin, Dec 21, 2006
    #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. mr2_93
    Replies:
    1
    Views:
    3,586
    mr2_93
    Oct 2, 2005
  2. tshad
    Replies:
    8
    Views:
    2,209
    tshad
    Oct 19, 2005
  3. =?Utf-8?B?SnVhbmpv?=

    GridView: Filtr DropDownList from another DropDownList

    =?Utf-8?B?SnVhbmpv?=, Dec 23, 2005, in forum: ASP .Net
    Replies:
    0
    Views:
    1,851
    =?Utf-8?B?SnVhbmpv?=
    Dec 23, 2005
  4. =?Utf-8?B?SnVhbmpv?=

    GridView: Filter DropDownList for another DropDownList

    =?Utf-8?B?SnVhbmpv?=, Dec 29, 2005, in forum: ASP .Net
    Replies:
    0
    Views:
    1,286
    =?Utf-8?B?SnVhbmpv?=
    Dec 29, 2005
  5. keithb
    Replies:
    1
    Views:
    11,920
    shauns1
    Nov 1, 2006
Loading...

Share This Page