您好我是MVC的新手,我想在我的程序中添加一个功能,其中我有一个页面,其中包含客户详细信息以及他们放置的过去订单。但是在页面上,它还必须显示属于该订单的订单商品,就像他们在亚马逊上一样。
我的客户详情查看
(define (square-sum-even lst)
(square-sum (evens lst)))
订单型号
<header class="panel-heading">
Customer Details
</header>
<div class="panel-body">
<dl class="dl-horizontal">
<dt style=" font-size: large; float:left">
Name:
</dt>
<dd style="font-size:large;margin-left:15px; float:left">
@Html.DisplayFor(model => model.customer_name)
@Html.DisplayFor(model => model.customer_surname)
</dd>
<dt style=" font-size: large; float:left">
Cellphone:
</dt>
<dd style="font-size:large;margin-left:15px; float:left">
@Html.DisplayFor(model => model.customer_cell)
</dd>
<dt style=" font-size: large; float:left">
Email:
</dt>
<dd style="font-size:large;margin-left:15px; float:left">
@Html.DisplayFor(model => model.customer_email)
</dd>
<dt style=" font-size: large; float:left">
Address:
</dt>
<dd style="font-size:large;margin-left:15px; float:left">
@Html.DisplayFor(model => model.customer_addressline1)<br />
@Html.DisplayFor(model => model.customer_addressline2)<br />
@Html.DisplayFor(model => model.customer_addressline3)
</dd>
<dt style=" font-size: large; float:left">
Join Date:
</dt>
<dd style="font-size:large;margin-left:15px; float:left">
@Html.DisplayFor(model => model.customer_join_date)
</dd>
</dl>
</div>
</section>
</div>
我的Item_Order模型
public class ORDER
{
[DisplayName("Order ID")]
public int OrderID { get; set; }
[DisplayName("Customer ID")]
public int CustomerID { get; set; }
[DisplayName("Batch ID")]
public Nullable<int> DeliveryID { get; set; }
[DisplayName("Employee ID")]
public int EmployeeID { get; set; }
[DisplayName("Date")]
[DataType(DataType.Date)]
[DisplayFormat(DataFormatString = "{0:yyyy/MM/dd}", ApplyFormatInEditMode = true)]
public System.DateTime order_date { get; set; }
[DisplayName("Time")]
[DataType(DataType.Time)]
[DisplayFormat(DataFormatString="{0:H:mm}",ApplyFormatInEditMode=true)]
public System.DateTime order_time { get; set; }
[DisplayName("Status")]
public String order_status { get; set; }
[DisplayName("Preferred Date")]
[DisplayFormat(DataFormatString = "{0:yyyy/MM/dd}", ApplyFormatInEditMode = true)]
public System.DateTime order_preffered_date { get; set; }
public virtual DELIVERY DELIVERY { get; set; }
public virtual CUSTOMER CUSTOMER { get; set; }
public virtual EMPLOYEE EMPLOYEE { get; set; }
public virtual ICollection<ITEM_ORDER> ITEM_ORDER { get; set; }
}
Item_Order VM
public class ITEM_ORDER
{
public int Item_OrderID { get; set; }
public int ItemID { get; set; }
public int OrderID { get; set; }
[DisplayName("Quantity")]
[Range(1, int.MaxValue, ErrorMessage = "Quantity must be greater than 0")]
public int item_order_quantity { get; set; }
public virtual ITEM ITEM { get; set; }
public virtual ORDER ORDER { get; set; }
}
答案 0 :(得分:0)
你想要呈现一个项目列表,所以你需要迭代它们,如下所示:
<table id="orderTable">
@foreach (var order in Model.Orders)
{
<tr>
<td>@order.date</td>
<td>@order.id</td>
<td>@order.customerName</td>
</tr>
}
</table>
@Dan Beaulieu:那是解决问题的问题,因为他(在评论中)询问如何在ordersList中显示项目,这就是我想的方式......无论如何,我扩展了答案,但我无法做更多提供的信息