【发布时间】:2013-02-22 17:35:03
【问题描述】:
我正在尝试为输入创建一个订单表单。
我需要用户能够添加多个订单项然后更新。我试图 使用购物车类(用户创建一个购物车项目并添加一个 列表项,可以在列表项中添加多行)。
我没有解决这个问题。我正在使用 asp.net razor 正在使用
webmatrix 建立网站。 Webmatrix 说它无法识别 Cart()。
@{
if (Session["cart"] == null)
{
Session["cart"] = new Cart();
}
Cart cart = (Cart)Session["cart"];
}
<table id="cartTable">
<tr>
<th class="product">Product</th>
<th class="size">Size</th>
<th class="price">Price</th>
</tr>
@foreach (var item in cart.Items)
{
<tr>
<td class="product">@item.ProductID</td>
<td class="size">@item.Size</td>
<td class="price">£@item.Price</td>
</tr>
}
</table>
有没有更好的方法来做到这一点?非常感谢所有帮助
【问题讨论】:
标签: asp.net asp.net-mvc asp.net-mvc-3 razor webmatrix