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

How do I use data binding in GenericDropDown

I have tried following the examples in the documentation but they are too simplistic and not helpful.  There is no example and source available on the website.  Can you please post a clear example that uses MVC 4, populating the drop-down with a list of items in the controller.  The items just need to have an int ID and a string NAME.  The strings and IDs come from a database, so I cannot manually write out the list in code.

I have tried putting the list in ViewData in the controller and using:
@{ Html.Syncfusion().GenericDropDown("SecondPhaseID").Render(); }

I have tried using GenericDropDownFields and GenericDropDownModel to make a model that is put in ViewData and using:
@(Html.Syncfusion().GenericDropDown("MyGenericDropDown", ViewData["myGenericDropDownModel"]))

and every variation off of that that I can think of.  When I run the page, the control does not appear.  I can put a breakpoint, but nothing shows on the page.  If I manually create a list in the control and fill the Items collection, then the control will appear.  But using my code, the Items array has a count of 0, but the DataSource has the correct list of items.  I do not know if that is correct behavior or not because there is almost no documentation that I can find.  Please help me with a very detailed example, thank you.

1 Reply

GA Gurunathan A Syncfusion Team October 3, 2013 06:44 AM UTC

Hi Pete,


Thanks for contacting Syncfusion support.


Your requirement of Generic DropDown with Databinding option can be achieved by setting the field of GenericDropDownField related to generic list and then assign the Datasource and bind the fields to GenericDropDownModel. Hence forth you can get the bind values in View page.





public ActionResult ToolsFeatures()



            ViewData["DropdownData"] = new Student1DataContext().Student1;


            GenericDropDownFields genericdropdownFields = new GenericDropDownFields()




                Id = "UniversityCode",


                Text = "Title"               




            GenericDropDownModel genericdropdownModel = new GenericDropDownModel()




                DataSource =(System.Collections.IEnumerable)ViewData["DropdownData"],  //Bindling Datasource with Generic list


                BindTo = genericdropdownFields,                                        //Binding Items with Generic DropDown fields


                ClientSideOnClick = "ClientSideOnClick",                               //Binding ClientSideOnClick event





            ViewData["myGenericDropDownModel"] = genericdropdownModel;                 //Binding dynamically created model to Viewdata


            return View();








We have provided information about Generic DropDown with Data binding concept in our documentation. The documentation is available in following link.




We have also prepared a simple sample to explicit this behavior. It can be downloaded from below given link




Warm Regards,


Live Chat Icon For mobile
Up arrow icon