Cs代码写在html页面哪里,当用于在details.cshtml页面上查看时,我用什么代码来查看模型中的项目列表?...
我正在嘗試查看銷售訂單中的產品列表。它看起來像這樣:
名稱OrderDate OrderTotal Products購買<<
被帶來的產品。銷售訂單連接到SalesorderProduct的橋接表。有什么建議。我知道它想要遍歷模型,但無法弄明白。
@Html.DisplayFor(model => model.Customer.Name)
@Html.DisplayFor(model => model.OrderDate);
@Html.DisplayFor(model => model.OrderTotal);
@Html.DisplayFor(model => model.SalesOrderProducts);
答案
嘗試這樣的事情:
@model SalesOrder
@{
ViewBag.Title = "View";
}
View
SalesOrder
@Html.DisplayNameFor(model => model.Name)
@Html.DisplayFor(model => model.Name)
@Html.DisplayNameFor(model => model.OrderDate)
@Html.DisplayFor(model => model.OrderDate)
@Html.DisplayNameFor(model => model.OrderTotal)
@Html.DisplayFor(model => model.OrderTotal)
@foreach (Product p in Model.SalesOrderProducts)
{
@Html.DisplayNameFor(x => x.Name)
@Html.DisplayFor(x => x.Name)
}
@Html.ActionLink("Edit", "Edit", new { id = Model.SalesOrderId }) |
@Html.ActionLink("Back to List", "Index")
總結
以上是生活随笔為你收集整理的Cs代码写在html页面哪里,当用于在details.cshtml页面上查看时,我用什么代码来查看模型中的项目列表?...的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Java反编译工具-luyten
- 下一篇: docker 定时重启脚本_使用 Go