I have read through this question ASP.NET MVC DropDownListFor not selecting value from model and answer but I don\'t know the solution to my problem.
This is my vi
In my opinion one item of the ViewBag.ForeignLanguages
should have Selected
property set to true
. DropDownListFor method select item based on ModelState. Here you have source code of DropDownListFor method an there is something like:
object defaultValue = (allowMultiple) ? htmlHelper.GetModelStateValue(fullName, typeof(string[])) : htmlHelper.GetModelStateValue(fullName, typeof(string));
And if that value is null then selected value is retrieved from Selected
property