0

I want to create drop down list in a foreach loop, and send list of those drop downs to view and enumerate them there.

how can i accomplish that?

View bags only hold one, like for instance i have 3 location drop down lists, i want to loop through country, region, city, and create drop down for each and send them to view.

note: it's not always 3 locations, locations are added dynamically with pointer to parent Id, so i have a list of parent locations for the final selected location (in this example i have city, and i want to backtrack to country while creating the appropriate drop down lists)

i'm using asp.net MVC 5

user5049376
  • 1,322
  • 2
  • 14
  • 19
  • You will have to use Ajax for this. So when one dropdown changes load the values of the other dropdown. Check out this answer: http://stackoverflow.com/a/30090363/1910735 – Dawood Awan Nov 01 '15 at 16:27
  • Refer also [this answer](http://stackoverflow.com/questions/28627421/better-way-to-load-2-dropdown-in-mvc/28640420#28640420) and this [DotNetFiddle](https://dotnetfiddle.net/JofdB8) –  Nov 01 '15 at 21:18
  • Thank you both for your comments, but i already do it with ajax like you said, but after the user selects the city, if he wants to edit this page later, i'll have to back track using the city and display the region, country drop downs also, that's what i want to know how to do? – user5049376 Nov 02 '15 at 05:59

1 Answers1

0

Thanks for the comments, but i solved this issue by using ajax to back track parent ids instead of using multiple drop downs and sending them to view.

user5049376
  • 1,322
  • 2
  • 14
  • 19