ASP.NET Web Forms DropDownList has a SelectedValue which is invalid because it does not exist in the list of items

前端 未结 6 990
孤独总比滥情好
孤独总比滥情好 2021-02-02 15:05

First of all there has been questions ( DropDownList has a SelectedValue which is invalid because it does not exist in the list of items , DropDownList "has a SelectedValue

6条回答
  •  忘了有多久
    2021-02-02 15:43

    I've submitted a bug on Connect for the issue. It was resolved as "Won't fix" which in my mind means it is in fact a bug. A workaround was provided:

    ddlTest.Items.Clear();
    ddlTest.SelectedValue = null;
    

    https://connect.microsoft.com/VisualStudio/feedback/details/666808/asp-net-dropdownlist-selectedvalue-is-persisted-which-results-in-exception-if-the-control-is-databound-second-time

    I kind of consider this the answer.

提交回复
热议问题