I have List<SelectListItem>
variable with two values. I want to represent it as dropdown box in html so I'm doing like this.
<div class="form-group row">
<label asp-for="Roles" class="col-sm-2 col-sm-offset-2 form-control-label"></label>
<div class="col-md-6">
<select asp-for="Roles" asp-items="@Model.Roles" class="form-control selectpicker bs-select-hidden"></select>
</div>
</div>
and this code shows me the list with those two items, but it also generates
multiple="multiple"
attribute for select tag.
How can I make not to generate multiple attribute?
asp-for
at can apparently contain multiple values. So, if it currently contains, say, two items (and yourasp-items
has more than two items in it), how is it meant to know which one item to mark asselected
? What happens to the other item when your form is submitted? – Surmise