I'm trying to use the new
ListBox control to map a simple select list like this:
Dictionary<string, object> htmlAttr = new Dictionary<string, object>();
htmlAttr.Add("name", "IDs");
List<SelectListItem> list = new List<SelectListItem>();
list.Add(new SelectListItem { Value = "1", Text = "Admin" });
list.Add(new SelectListItem { Value = "2", Text = "Technician" });
@Html.EJS().ListBox("lbList").DataSource(list).Fields(new ListBoxFieldSettings { Value = "Value", Text = "Text" }).SelectionSettings(new ListBoxSelectionSettings { ShowCheckbox = true, Mode = SelectionMode.Multiple }).Value("1,2".Split(',')).HtmlAttributes(htmlAttr).Render()
I do it the same way with MultiSelect and it maps the value on submit correctly, however, when using ListBox, it doesn't map the Value property of my list but the Text property instead. I can confirm it when looking at the html source:
<select class="e-hidden-select" multiple="" name="IDs"><option selected="" value="Admin"></option><option selected="" value="Technician"></option></select>