【发布时间】:2021-11-25 03:37:12
【问题描述】:
在这种情况下,有两个表。一个是项目信息,另一个是项目佣金。在项目表中有三列 - 项目 ID、项目名称和价格。在项目佣金表中有佣金 ID、项目 ID 和佣金率三列。 在视图中,我需要显示项目信息表中的项目名称和项目佣金表中的佣金率。 在这种情况下,我使用 linq 来连接两个表。
我创建了一个列表并想在 mvc5 中显示它,但出现错误。代码如下:
@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>
}```
【问题讨论】:
-
错误是什么?
-
通常有助于告诉我们错误,以及抛出错误的行。
标签: c# asp.net-mvc-5