Multiple crashes in Dropdownlist asp.net MVC 3

Can I select multiple items from a razor drop-down control? for

@ Html.DropDownListFor (m => m.Country, CountryList as SelectList, "- Select -")

+5
source share
3 answers

You can try, maybe something like this ...

@Html.ListBoxFor(m=>m.Country, new MultiSelectList(CountryList as SelectList, "CountryID", "Select"))
+13
source

You just need to add new { "multiple" = "multiple" }functions as the last parameter - this will be done by the multi selector.

+8
source

( Id Name), List of SelectListItem :

List<SelectListItem> Choices = Items.Select(x => new SelectListItem { Value = Convert.ToString(x.Id).Trim(), Text = x.Name }).ToList();

@Html.ListBox("ListBoxIds", new MultiSelectList(Choices, "Value", "Text"))

ListBoxIds .

0

All Articles