In this example, we populate two DropDownLists. One for Department List and another for Designation List. The Department list is first executed. Then, on the basis of the selected department name, the designation list is populated.
For this, first we need to create two model classes for Department and Designation as below.
Now to create the Controller. For that, we first create the following method to populate the department list.
Now we want to write the method to populate the designation. This method will take DeptCode as an argument and provide only those designation lists tagged with the given department.
Now to design the view. For the view, please use the following code.