Why is my selected value showing up twice in a dropdownlist (asp.net mvc)


Why is my selected value showing up twice in a dropdownlist (asp.net mvc)



i have an asp.net mvc view with the following code to show a dropdown list:

 <% = Html.DropDownList("filter", Model.MyList, Model.MyDefaultValue, new { @id = "filter", @class = "complete" })%> 

Model.MyList is a List with my items and one blank one at top and Model.MYDefaultValue is a string.

When i run this it looks like it works but i get my default listed twice

so lets say my list is:

Ford
Toyota
Chevy

and my Default is Toyota

when i click on the drop down i get:

Toyota

Ford
Toyota
Chevy

you see Toyota was added as the first item and as the 4th item.


How to NOT route files & directories to ASP.NET MVC

1:

Object gets disconnected from nHibernate session after TryUpdateModel is called
The Html.DropDownList() method accepts an optionLabel string parameter, the text of which is inserted at the top of the dropdown list (with an empty value). Validating that a form input is not emptyIt doesn't necessarily have anything to did with which item of the list is selected.. Value from Hidden Input field as an Actionlink Parameter You could create a SelectList using your MyList and specify a selected value (see SelectList Constructor) before passing it to Html.DropDownList().. How to send jQuery $.get so the Model Binder can bind a string to a parameter?
Adding check boxes to each row on MVCcontrib Grid

84 out of 100 based on 39 user ratings 194 reviews

@