Multi Select DropDownList

Hi there,

I have another issue where I have a Multi Select Drop Down List which passes back this to the controller:

I only need to pick up the two GUID's rather than the two names. This is inside a inline form template on a grid, where I dimension a <select> tag on the template and change it to a Syncfusion Drop Down List:

$("#PublicationId").ejDropDownList({
                                    dataSource: newItems,
                                    fields: {
                                        text: "Name",
                                        value: "Id",
                                        selected: "Selected"
                                    },
                                    showCheckbox: true,
                                    multiSelectMode: ej.MultiSelectMode.VisualMode,
                                    validationRules: { required: true },
                                    validationMessage: { required: "Please choose at least one Publication" }                               
                                });

I only need to capture the value's of the selected items rather than the Names plus the Values.

Can you please help?

What does the variable need to be at the controller in order to capture this?

Many thanks,

Frankie

1 Reply

KV Karthikeyan Viswanathan Syncfusion Team October 18, 2017 10:12 AM UTC

Hi Frankie Moran,  
 
Thanks for contacting Syncfusion Support.  
 
For your case, You can use DropDownListFor instead of using selected values rather than names,  
 
Please find the MVC samplebrowser sample link: http://mvc.syncfusion.com/demos/web/dropdownlist/dropdownlistfor  
 
Code example: 
<code> 
View: 
 
@Html.EJ().DropDownListFor(model => model.ddl, (Syncfusion.JavaScript.Models.DropDownListProperties)ViewData["ddl"]).WatermarkText("Select a car").Width("100%")
 
 
 
 
CS: 
public ActionResult DropdownlistFor() 
        { 
            DropDownListProperties ddl = new DropDownListProperties(); 
            ddl.DataSource = GetDataSource(); 
            DropDownListFields ddf = new DropDownListFields(); 
            ddf.Text = "text"; 
            ddf.Id = "uniqueKey"; 
            ddl.DropDownListFields = ddf; 
 
            ViewData["ddl"] = ddl; 
 
            return View(); 
        } 
 
        [HttpPost] 
        public ActionResult DropdownlistFor(DDL model) 
        { 
            DropDownListProperties ddl = new DropDownListProperties(); 
            ddl.DataSource = GetDataSource(); 
            DropDownListFields ddf = new DropDownListFields(); 
            ddf.Text = "text"; 
            ddf.Id = "uniqueKey"; 
            ddl.DropDownListFields = ddf; 
 
            ViewData["ddl"] = ddl; 
 
            return View(model); 
        } 
 
 
</code> 
 
 
Regards, 
Karthikeyan V. 


Loader.
Up arrow icon