December 2, 2015

ASP.Net Error Cannot have multiple items selected in a DropDownList

If you are getting exception like "Cannot have multiple items selected in a DropDownList", its most probable cause is you are using below line in your application

ddlItems.FindByValue("data").Selected = true;

To handle this error, you need to clear the previous selection of your drop down as following:

ddlItems.ClearSelection();
ddlItems.FindByValue("data").Selected = true;

Thanks
Enjoy Learning.

No comments:

Post a Comment