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

Duplicate selected values in multiselect dropdownlist


I got a problem with a multiselect Dropdownlist. I set the datasource with my model and set the datafields value, text and selected. But in the view my selected entries are duplicated. The property "SelectedSpecializationDefinitions" is an empty string array and in the property SpecializaionDefinition you can find the objects (see screenshot "ej.CreateObject....")

What I'm doing wrong? 

Kind regards,

     <div class="form-group">
            @Html.LabelFor(model => model.StationaryAsset.SelectedSpecializationDefinitions, htmlAttributes: new { @class = "control-label col-md-4" })
            <div class="col-md-8">
                @(Html.EJ().DropDownListFor(Model => Model.StationaryAsset.SelectedSpecializationDefinitions)
                    .DropDownListFields(df =>


3 Replies

KR Keerthana Rajendran Syncfusion Team May 25, 2017 11:15 AM UTC

Hi Carsten, 
Based on your code, we have prepared a sample to reproduce the reported issue. Unfortunately, we were unable to reproduce the reported issue at our end. Please refer the below given screenshot:   
Duplicated selected values are not found.  
Please refer to the below given link for sample 
If the issue persists ,kindly revert by modifying the above sample to reproduce the issue along with the details of product version which you are using. This will be helpful to analyze further and provide better solution at the earliest 
Keerthana R. 

CB Carsten Buchmann May 31, 2017 01:19 PM UTC

I found my mistake. The property "Id" must be of type string. But now I'm only getting nothing back in my post method. With your example from https://help.syncfusion.com/aspnetmvc/dropdownlist/stronglytypedhelper I tried to manage it but with no success.Here's your modified example with a post method: https://systmanu-my.sharepoint.com/personal/cbu_symplion_de/_layouts/15/guestaccess.aspx?docid=064e8037737a247aa9ace7587d03bf20e&authkey=AfPn3sM60elE-_rKZxXR4_Y Here you can see that in the HttpPost Index Method the viewModel got no selected items from the dropdownlist.

KR Keerthana Rajendran Syncfusion Team June 1, 2017 12:00 PM UTC

Hi Carsten, 
We checked the reported  issue in the attached sample. When selecting single item in DropDownList the selected value will be returned in DropDownList model and this will not work in case of multiple selection. We suggest you to follow the below work around in your sample to achieve the requirement.  
        public ActionResult Index(DropDownListModel model, string[] DropData) 
            ViewBag.datasource1 = data; 
            DropDownListProperties ddl = new DropDownListProperties(); 
            ddl.DataSource = DropData; 
            ddl.Value = string.Join(",", DropData); 
            DropDownListFields ddf = new DropDownListFields(); 
            ddf.Text = "Description"; 
            //ddf.Value = "id"; <-- leads to duplicated selected values 
            ddf.Value = "Description"; 
            ddf.Id = "id"; 
            ddf.Selected = "Checked"; 
            ddl.DropDownListFields = ddf; 
            ViewData["ddl"] = ddl; 
            return View(model); 
Pass the value of DropDownList in Post method  and join the values using string.Join() and assign this data to DropDownList datasource. 
We have modified the sample by including these changes. Please refer to the below given link 
Keerthana R. 

Live Chat Icon For mobile
Up arrow icon