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. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How do I use data binding in GenericDropDown

Thread ID:





112530 Sep 26,2013 04:57 PM UTC Oct 3,2013 06:44 AM UTC ASP.NET MVC (Classic) 1
Tags: Tools
Asked On September 26, 2013 04:57 PM UTC

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.

Gurunathan A [Syncfusion]
Replied On 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,



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.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon 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.Close Icon