We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Listbox mapping Text instead of Value / Id

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>

4 Replies

VK Vinoth Kumar Sundara Moorthy Syncfusion Team April 8, 2019 12:58 PM UTC

Hi Juan, 
Thank you using Syncfusion products. 
We have checked your reported issue “Listbox mapping Text instead of Value / Id” and we are able to reproduce it in our end. And we confirmed the reported issue is a defect and logged the defect report for the same. We have planned to include the fix for this issue in our upcoming EJ2 patch release. We appreciate your patience until then.  
You can track the status of defect using below link from our feedback portal. 
Vinoth Kumar S 

VK Vinoth Kumar Sundara Moorthy Syncfusion Team April 10, 2019 05:27 PM UTC

Hi Juan, 
Thank you for your patience. 
We are glad to announce that our Essential JavaScript 2 patch release (v17.1.40) has been rolled out successfully and in that release, we have added the fix for “Listbox mapping Text instead of Value / Id” in our updated online nuget packages. So you can update the nuget packages and use the updated JS file to resolve this issue in your end. Please find the links below. 
Please get back to us if you need further assistance.    
Vinoth Kumar S 

JJ Juan Jiminez April 10, 2019 05:54 PM UTC

I confirm the patch works.

Thanks Vinoth!

VK Vinoth Kumar Sundara Moorthy Syncfusion Team April 11, 2019 06:21 AM UTC

Hi Juan, 
You are most welcome. Please feel free to contact us if you need any further assistance on Syncfusion components. 
Vinoth Kumar S 

Live Chat Icon For mobile
Up arrow icon