Le Tuan

Le Tuan

  • NA
  • 4
  • 586

Binding two entities to dropdownlist in one view

May 2 2018 9:22 AM
Hi all,
I am a newbie MVC5 and Entity Framework 6. 
I have 3 tables: Employee (id (pk), name, departmentID(fk), jobtileID(pk),...), Department(departmentID(pk), name,...) and Jobtile(jobtitleID(pk), titleName,...).
I would like to buitd a website to allow users to add employee to the database.
The website has a view to list all Employee using EF with these information: id, name, departmentName, titleName,...) in a table.
When an user selects Add new button, a new view allows user to add name, select an department from dropdownlist and select jobtile from another dropdownlist.
While the user selects Edit button a view allows user to edit Employee Information as employee name, department and jobtitle display correctly in edit view.
I want to use zaror to bind data to dropdownlist using dropdownlistfor
How to solve this problem. Thank in advanced.

Answers (1)