I would advise you to use such a type-safe design:
<% = Html.DropDownListFor(x => x.IncludesWeekends, new SelectList(Model.YesNoList, "Value", "Text"), new { @id = "IncludesWeekends" })%>
instead of this:
<% = Html.DropDownList("IncludesWeekends", Model.YesNoList, new { @id = "IncludesWeekends" })%>
You get a lot - a strongly typed lambda expression bound to a given property of the model, instead of the name of the property hardcoded as a magic string. Using this construct, you automatically get intelli-sense tools, refactoring, and compiler support. Strongly typed helpers exist in MVC since version 2.0, so it makes no sense to use the old ones.
Next, change the value of the IncludesWeekends model to pre-select the desired parameter. In your case, this means changing the type of IncludesWeekends to string instead of bool and assigning it the value "0" or "1" . Alternatively, if you do not want to change the IncludesWeekends type, add an additional property to your model, for example. SelectedValue and make minor changes:
In action:
vm.SelectedValue = vm.IncludesWeekends ? "1" : "0";
in view:
Html.DropDownListFor(x => x.SelectedValue, ...
You do not need to use the Selected SelectListItem property - ignore it and remove all references to it.
source share