In this case there are two tables. One is item info another is item commission. In item table there are three columns - item ID, item name and price. In the item commission table there are three columns commission ID, item ID and rate of commission. In the view I need to show item name from the item info table and rate of commission from item commission table. In this case I have used linq for joining two tables.
I made a list and want to show it in view in mvc5 but get an error. Here is the code:
@model IEnumerable<FRANCHISEE.Models.FrcItemList>
@{
ViewBag.Title = "FranchiseeItemList";
}
<p>
@Html.ActionLink("Create New", "Create")
</p>
<table class="table">
<tr>
<th>
@Html.DisplayNameFor(model => model.ItemName)
</th>
<th>
@Html.DisplayNameFor(model => model.Roc)
</th>
<th>
@Html.DisplayNameFor(model => model.FrcItemId)
</th>
<th></th>
</tr>
@foreach (var item in Model)
{
<tr>
<td>
@Html.DisplayFor(modelItem => item.ItemName)
</td>
<td>
@Html.DisplayFor(modelItem => item.Roc)
</td>
<td>
@Html.ActionLink("Edit", "Edit", new { /* id=item.PrimaryKey */ }) |
@Html.ActionLink("Details", "Details", new { /* id=item.PrimaryKey */ }) |
@Html.ActionLink("Delete", "Delete", new { /* id=item.PrimaryKey */ })
</td>
</tr>
}```