System.Web.HttpException: Cannot have multiple items selected in a DropDownList

后端 未结 3 573
我在风中等你
我在风中等你 2021-02-03 11:55

During page load, index 0 was already selected. Then this code statement selected index 1:

dropDownList.Items.FindByValue(myValue).Selected = true; 
// assume my         


        
3条回答
  •  悲&欢浪女
    2021-02-03 12:35

    I had a similar problem but under a slightly different scenario. I thought I should post it and the resolution here as it may help someone save time if they happen to be in my similar scenario.

    First the error message:

    AMError: Sys.WebForms.PageRequestManagerServerErrorException:
    Sys.WebForms.PageRequestManagerServerErrorException: 
    Cannot have multiple items selected in a DropDownList.
    

    My Scenario:

    I was using using VisualStudio 2010 to step through the application (ASP VB Net) when I encountered the problem. I looked over the 2 dropdownlists on the page, checked the internet and wasted several hours w/o any resolution.

    Resolution:

    Then I got feedup and exited VS 2010 and took a break. When I came back. I reran the application and there was no problem. That's when I realized my costly mistake: I had setup an expression that set the SelectedValue in the Debugger Watch Window! Hence the multiplicity!

    I removed the expression and all was well again --- Visual Studion 2010 able to get past the dropdownlist section onto the another area of focus of the application.

提交回复
热议问题