I have problem with binding 2 models in 1 view. Here is my view code:
@model IEnumerable<PEMCOLoan.DAL.Entities.Models.Employee>
@model PEMCOLoan.DAL.Entities.Models.Employee
The IEnumerable
uses to generate all employees into tables and the other one will be used to add/edit/delete... I already have functionalities on those operator how ever when viewing data I got error.
Is there anyway that I could bind 2 the same model with different function at the same time in 1 view?
Is there anyway that I could bind 2 the same model with different function at the same time in 1 view?
No.
Create one view-model that has both as properties.
public class MyViewModel {
public IEnumerable<PEMCOLoan.DAL.Entities.Models.Employee> Employees { get; set;}
public PEMCOLoan.DAL.Entities.Models.Employee Employee { get; set;}
}
that way when populated and passed to the view you can access them both via the wrapping model.
@model MyViewModel
@foreach(var e in Model.Employees) {
<p>@e.Property</p>
}
<p>@Model.Employee.Property</p>