Cascading dropdowns
You can add drop-down menus to almost any Bootstrap component using the dropdown plugin. A cascading drop-down menu is a drop-down menu that updates its data based on a value selected in another drop-down menu. To add cascading drop-down menus, perform the following steps:
- Inside Visual Studio, add a new controller called
DropdownController.csto yourControllersfolder. - In the
Indexaction, add the following code, which will create a list of managers and load a list of reporting employees for the selected manager:public IActionResult Index(int id = 2) { var managers = new List<EmployeeModel>(); var vicePresident = new EmployeeModel { Id = 2, Name = "Andrew Fuller", JobTitle = "Vice President, Sales", ReportsTo = null }; ...