Filling a DropDownList based on another DropDownList (Cascading Drop Down)

I am having trouble getting the necessary functionality in our Create View in our ASP.NET MVC application.

We have two DropDownLists in our Create view.

One is category selection, and the second should be populated with elements based on the id value of the selected first category. (They are related to FC).

Have you guys come across any similar situation, and can you give me some advice or a hint on how I can solve this problem best?

  • Should I create a specific ActionResult method for this?
  • Or do I need to use the static method in the repository / controller?

All help is more than appreciated!

+4
source share
2 answers

You are looking for Cascading Drop Down .

+3
source

Just to clarify what NicklLarsen said

If you want them to refresh on the page without having to reload after each selection of the first drop-down list, you will want to use cascading drop-down lists

Drop-down cascading shortcuts are short for invoking AJAX to another action method with the selected value of the first drop-down list. The action method takes this value, uses it to search for relevant information based on this value, and returns the JSON / XML format of the list of elements. Using javascript, you then update the second dropdown with the elements.

+3
source

Source: https://habr.com/ru/post/1300810/


All Articles