ThreadAbortException

May 2006 Entries

Microsoft Tech Ed India 2006 - Its festival season for Tech lovers !!!





It is that part of the year when Microsoft Tech Ed rocks the country across cities and this year there is more to learn.

Tech Ed India 2006 is being hosted in 6 cities with three separate tracks specifically for Developers, Architects and IT Professionals.

And that is not all, there are a lot of Contests, Videos, Seminars as well as fun and excitement activities around the corner.

For more details visit
Microsoft Tech Ed 2006

Cheers and Happy Technology Days !!!

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

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 !!!