How to display only department fields associated with a selected department in student automation
hi,
I'm facing a challenge while working on the student automation system. After selecting the department field in the form, I want to display only the departments associated with the selected unit in the department field. Currently, I can see that the units are listed correctly in the unit selection dropdown, but all departments are listed in the department selection dropdown and not filtered.
I'm struggling to find a solution for this. How can I display only the departments associated with the selected unit in the department field after selecting a unit? Do I need to edit my existing code or develop a new approach for this?
Controller.cs:
AddStudent.cshtml:
Thank you.
2 Replies
Start by not using the
ViewBag
Your view declares that the @model
for it will be of type Student
Yet you don't pass any model to the View()
method
Far as selecting the data you want, in the shape you need... I assume you're using EF Core here
If so, then utilize LINQ
Don't just dump the entire databasetnx