When you use the strongly-typed html helper for a DropDownList (Html.DropDownListFor
), the Selected
property of SelectListItem
is overwritten by the value of your Model Property. It makes sense. So, when you use the Html Helper like below, the selected value will be Model.AnimalNumber
. Since, the default value for an int
is 0, when you create a new Model, and send it to your View, the value of its int
properties are defaulted to 0. So, in this case, Model.AnimalNumber
is 0, and therefore, the selected value of the DropDownList is the item with the value of 0.
@Html.DropDownListFor(m => m.AnimalNumber, Animal.ListAnimals())
In order to solve that issue, you can either change the type of your property to int?
or you can make sure that the value of none of your SelectListItem
s is 0, or you can set a default value for your property (in this case AnimalNumber = -1
).