【发布时间】:2019-05-03 08:57:10
【问题描述】:
我在一次销售的模型中有一个列表,并且我在其中显示了所有产品,但是,现在我需要显示类别描述,(一次)来自seme类别的每个产品,怎么办?
Product Quantity Price
*Licors (This is the category)
Brugal 1 500
Barcelo 15 700
*Fruits (This is the category)
Apple 1 25
Banana 3 5
我需要显示的是(向上)产品名称上的描述 @Html.DisplayFor(modelItem => item.Product.Category.Description)
这是我的代码
<table>
<thead>
<tr>
<th class="center"></th>
<th>Serv./Prod.</th>
<th class="center">Cant.</th>
<th class="right">Precio</th>
</tr>
</thead>
<tbody>
@foreach (var item in Model.SalesDetails.OrderBy(p=>p.Product.CategoryId))
{
<tr>
<td class="center"></td>
<td class="left"> @Html.DisplayFor(modelItem => item.Product.Name)</td>
<td class="right"> @Html.DisplayFor(modelItem => item.Quantity)</td>
<td class="center"> @Html.DisplayFor(modelItem => item.Product.SellPrice)</td>
</tr>
}
</tbody>
</table>
【问题讨论】:
-
描述在哪里?
-
在foreach里面吗?
-
@TAHASULTANTEMURI 为什么你的名字对我大喊大叫?
-
@FrankerZ 对不起,先生,我无法理解您的意思
-
Product.CategoryId 有一个 Product.Category.Description
标签: c# asp.net asp.net-mvc web