November Happy Hour will be moved to Thursday December 5th.

auto populate dropdown from the database

Vote:
 

Hi,

I have to create a page which lists 4 dropdowns and a body text.

First dropdown should get populated with the values from a database table. Based on the selections(single or multiple) in the first dropdown, second dropdown should get populated with the another database table taking the input parameters from the first dropdown, similary for 3rd and 4th. 

Body text should appear with the selected values and some other text.

I want to know how do we populate the dropdowns with the database values. Could anyone please help. Do we have any sample example?

#144922
Feb 22, 2016 17:22
Vote:
 

This is really a.NET question but normally you have some kind of ORM mapper like Entity Framework to read values from database. Then you extend the view model with the data you need. Check out alloy site where they have a few examples. Fill the view model in controller with the help of your ORM repository classes. Render them in view using the standard razor syntax. See example code plus alloy example site for Episerver.

http://www.c-sharpcorner.com/UploadFile/4d9083/creating-simple-cascading-dropdownlist-in-mvc-4-using-razor/

#144925
Feb 22, 2016 17:50
Vote:
 

If you are looking into doing this in edit mode (if dojo part is your problem), take a look into this post:

http://world.episerver.com/blogs/Duong-Nguyen/Dates/2014/1/Country-Region-drop-down-lists-in-All-properties-mode/

#146608
Mar 18, 2016 17:33
This thread is locked and should be used for reference only. Please use the Episerver CMS 7 and earlier versions forum to open new discussions.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.