How to display data from another table?
Hey guys, imagine i have two tables, employee and company.
the employee has the follow colums: Id , name and company (wich is a foreign key from the table company)
now i created a employee model wich declairs the company column this way: public company company { get; set; }
On the view page i want to list all employees and the name of the company and i use @foreach (var item in Model) to list all employees, when i want to display the company name i would use something like this @Html.DisplayFor(modelItem => item.company.name) but it wont display the name of the company (of course because the code could be something else), can any one help me getting to display the name of the companys ? Thanks!
0 comments:
Post a Comment