Cannot have multiple items selected in a DropDownList

Make sure you are not databinding multiple ddls to the same datasource. Being selected is an attribute of an item, therefore, if different ddls select different items from the same datasource, each of the ddls ends up with multiple items selected which is probably what is happening here..


This code will solve this issue:

YourDropDownId.ClearSelection(); 

Usually this error occurs when you load your ddl as following:

ddl.FindByValue("parameter").Selected = true; 

To overcome this error, you should clear the previous selection of your ddl as following:

ddl.ClearSelection();
ddl.FindByValue("parameter").Selected = true; 

Or you can do as following:

ddl.SelectedItem = "parameter";

I hope i could help someone. ;-)

Tags:

C#

.Net

Asp.Net