I have a form that contains a multiple selectlist and I also use bootstrap selectpicker with this.
code:
model:
[Display(Name = "SystemTyp")]
[Required(ErrorMessage = "Vänligen välj typ")]
public List<SelectListItem> SystemTypes { get; set; }
view:
<div class="form-group">
@Html.Label("SystemTyp", new { @class = "col-md-2 control-label" })
<div class="col-md-10">
@Html.DropDownList("SystemTypes",
RegistrationHandlers.GetSystemtypes()
,
new { @class = "form-control", @multiple = "multiple", @title = "--- Välj Systemtyp ---" })
@Html.ValidationMessageFor(model => model.SystemTypes, "", new { @class = "text-danger" })
</div>
</div>
When posting:
Every time I post the list is empty. The list name matches the model property name.
What am I missing?
I have another list that is a single select so the selected value is a simple string and this works fine but the above is giving me a headache.