Well, if your EmployeeDepartment
type looks like this:
public class EmployeeDepartment {
public int ID { get; set; }
// + other properties
}
Then you can just change your razor code to:
@Html.DropDownListFor(
m => m.EmployeeDepartment.ID,
new SelectList(@Model.AvailableDepartments , "Code", "Name")
)
And then, when you receive the model back in again, the model will contain a non-null EmployeeDepartment
with the ID set.
However, I think you're asking if you can then have the model binder automatically go and fetch the rest of the record from the database and fill in the rest of the data? If so, that's a more complex problem - but you can easily patch that up in the controller.