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.
Unfortunately, activation email could not send to your email. Please try again.

GenericDropDown DataSource MulitpleSelection Checkboxes

Thread ID:





107292 Feb 23,2013 01:08 AM Feb 25,2013 04:13 AM ASP.NET MVC (Classic) 1
Tags: Tools
Marie CG
Asked On February 23, 2013 01:08 AM

I am trying to implement GenericDropDown DataSource MulitpleSelection Checkboxes but ran into some difficulties.  Here is my code which is working with regular checkboxes in my view chtml:
<div class="editor-field">
                    List<gThiraMetrix.ViewModel.AssociatedThreatData> associatedThreatList = ViewBag.AssociatedThreats;
                    foreach (var th in associatedThreatList)
                        @: <div>
                            <input type="checkbox"
                                @(Html.Raw(th.Assigned ? "checked=\"checked\"" : "")) />
                                @th.ThreatID @: @th.Name
                        @: </div>  
Here is my code using Syncfusion.GenericDropDown but I dont see the checkboxes.
<div class="edit-field" >
                List<gThiraMetrix.ViewModel.AssociatedThreatData> associatedThreatList = ViewBag.AssociatedThreats;
                    .BindTo(bind =>
I am not sure what is wrong with this. Got any Idea?

Varalakshmi R.S [Syncfusion]
Replied On February 25, 2013 04:13 AM

Hi Marie,


Currently, we do not provide support to generate check box during data bind. However, this could be achieved by manually adding checkboxes to the GenericDropdown. We have prepared a simple sample to exhibit the check box list in Data bind and the sample can be downloaded from the link given below,


In the attached sample, we have dynamically added the checkboxes in the “ClientSideOnLoaded” event as given in the below code snippet,



@{Html.Syncfusion().GenericDropDown("myGenericDropDown", new { style = "display:inline-block;" })


            .BindTo(fields => fields









function ClientSideOnLoaded(sender, args) {

        //Adding checkbox dynamically to GDD control

        $("#myGenericDropDown_DropDownContainer").find(".gddChildItem").each(function (i, item) {

            var html = '<input type="checkbox" name="' + $(item).text() + '" value="' + $(item).text() + '" />';





Note:  AllowMultipleSelection  should be enabled to allow multiple selection.


The values of the checked items will be updated in the textbox using ClientAPI “setText” and this value can be passed to controller during post by including the GenericDropDown control inside Html.BeginForm. the retrieved values then splitted based on the separators to get the selected items collection. Please refer the below code,




        public ActionResult Index(string myGenericDropDown)


            //myGenericDropDown refers the value in the Textbox then split it using separator to retrieve the selected items collection

            IList<string> selectedItems = myGenericDropDown.Split(';').ToList();

            var data = SqlCE.Flags;

            return View(data);




Kindly try the attached sample or modify your sample based on the solution we provided and let us know if this helps.





This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.