I have created a bootstrap multiselect:
<div class="col-sm-4">
<div class="form-group">
<label for="providers" style="width:100%;">Provider :</label>
<select id="providers" multiple="multiple" class="form-control">
@foreach (var providers in @ViewBag.Providers)
{
<option value=@providers>@providers</option>
}
</select>
@Html.HiddenFor(m => m.providerString)
</div>
</div>
The options in @ViewBag.Providers are: Dr A B, Dr B C, Dr P Q, Dr periciado
After selecting multiple values, it always shows "Dr A B" in the selected textbox. I removed the spaces from the options value and it works correctly but it is not working with the values having multiple spaces.
Did you try putting quotes around the option's value?
<option value="@providers">@providers</option>
instead of
<option value=@providers>@providers</option>