An ASP.NET Blog
I work for Microsoft and help people and businesses make better use of technolgy to realize their full potential. The opinions mentioned herein are solely mine and do not reflect those of my employer.

ASP.NET Dropdownlist - "Cannot have multiple items selected in a DropDownList."

Wednesday, May 03, 2006 9:00 AM
You may receive the error "Cannot have multiple items selected in a DropDownList." when trying to set a value selected in an ASP.NET Dropdownlist.

This error specifically occurs if you are trying to execute a similar code as follows:-



DropDownList1.Items.FindByValue("3").Selected = true;

(or)

DropDownList1.Items.FindByText("Sports").Selected = true;

This error doesnt occur if you try to use

DropDownList1.SelectedIndex = 3;
or
DropDownList1.SelectedItem.Value = "3"; (Wrong way of implementation. But people use this)


The resolution is that, you just have to mention DropDownList1.ClearSelection(); before using D
ropDownList1.Items.FindByValue("3").Selected = true;

The correct step is as below:-

DropDownList1.ClearSelection();
DropDownList1.Items.FindByValue("3").Selected = true;

or

DropDownList1.ClearSelection();
DropDownList1.Items.FindByText("Sports").Selected = true;

In my next article I will discuss on the common misconception in making a particular Dropdownlist value selected.

Cheers and Happy Programming !!!

Feedback

# re: ASP.NET Dropdownlist - "Cannot have multiple items selected in a DropDownList."

this info was very useful to me

thanks for ur information 2/27/2007 11:05 AM | john michel

# re: ASP.NET Dropdownlist - "Cannot have multiple items selected in a DropDownList."

cheers been bugging me that one! 3/1/2007 3:58 PM | Lee Stevens

# re: ASP.NET Dropdownlist - "Cannot have multiple items selected in a DropDownList."

That solved a baffling error for me. Thanks! 3/9/2007 9:09 PM | Bill Kuhn

# re: ASP.NET Dropdownlist - "Cannot have multiple items selected in a DropDownList."

Thanks!!! You saved a food few hours!!!! 11/28/2007 8:09 AM | Ramy

# re: ASP.NET Dropdownlist - "Cannot have multiple items selected in a DropDownList."

Thanks,
We searched for that problem on Google and found at top. Nice Solution.
Good work,
Keep it up :) 12/12/2007 1:41 AM | Shail

# re: ASP.NET Dropdownlist - "Cannot have multiple items selected in a DropDownList."

This article was very useful to me and it is easily understandable 12/17/2007 5:20 PM | Praveena

# re: ASP.NET Dropdownlist - "Cannot have multiple items selected in a DropDownList."

Nice one. Saved my time. Cheers mate. 2/13/2008 9:58 PM | Hitz

# re: ASP.NET Dropdownlist - "Cannot have multiple items selected in a DropDownList."

Thanks. It helped me a lot.

Regards,
Shaik. 2/18/2008 6:12 PM | Shaik

# re: ASP.NET Dropdownlist - "Cannot have multiple items selected in a DropDownList."

Thanks..... i got an idea ....but what about it comes in master page not using FindByValue or text 2/25/2008 4:22 PM | Sankar

# re: ASP.NET Dropdownlist - "Cannot have multiple items selected in a DropDownList."

Ekdam Rapchik ha! 2/28/2008 4:24 PM | Eknath

# re: ASP.NET Dropdownlist - "Cannot have multiple items selected in a DropDownList."

Straight forward solution thnx 3/10/2008 3:04 AM | Sfinx

# re: ASP.NET Dropdownlist - "Cannot have multiple items selected in a DropDownList."

Thanks For The Help!! God Bless! 4/2/2008 4:48 PM | rishian

# re: ASP.NET Dropdownlist - "Cannot have multiple items selected in a DropDownList."

Thanks very much for the solution! 5/5/2008 4:19 AM | carlos

# re: ASP.NET Dropdownlist - "Cannot have multiple items selected in a DropDownList."

thanks for the help 5/8/2008 10:56 PM | abhishek

# re: ASP.NET Dropdownlist - "Cannot have multiple items selected in a DropDownList."

i had spend almost 3-4 hours to this error. After that the solution you had given, solved my problem
Thank you very much 5/9/2008 5:07 PM | Ravi Gupta

# re: ASP.NET Dropdownlist - "Cannot have multiple items selected in a DropDownList."

tnks you saved some debugging ours for me!! 5/22/2008 7:57 PM | Ashberger

# re: ASP.NET Dropdownlist - "Cannot have multiple items selected in a DropDownList."

Thank you so much..this is really useful..... 6/20/2008 12:43 AM | Kalaravi

# re: ASP.NET Dropdownlist - "Cannot have multiple items selected in a DropDownList."

Thanks 6/23/2008 4:03 AM | Bala

# re: ASP.NET Dropdownlist - "Cannot have multiple items selected in a DropDownList."

thanks a lot nice solution 6/30/2008 9:56 PM | sivaani

# re: ASP.NET Dropdownlist - "Cannot have multiple items selected in a DropDownList."

this saved a lot of time for me !!! nice post 7/7/2008 5:41 AM | Subhash

# re: ASP.NET Dropdownlist - "Cannot have multiple items selected in a DropDownList."

got my problem solved in seconds. 7/15/2008 8:26 PM | Ashish

# re: ASP.NET Dropdownlist - "Cannot have multiple items selected in a DropDownList."

thank for good article 7/29/2008 7:43 PM | chan myie

# re: ASP.NET Dropdownlist - "Cannot have multiple items selected in a DropDownList."

Thank you,got my problem solved in seconds. 8/10/2008 4:38 PM | Sunitha

# re: ASP.NET Dropdownlist - "Cannot have multiple items selected in a DropDownList."

Thank you very much 8/27/2008 12:33 AM | Shailesh

Post a comment





 

Please add 5 and 4 and type the answer here: