如何编辑与ASP.NET MVC3嵌套模型 [英] How to edit nested models with ASP.NET MVC3
问题描述
我希望做类似的东西来 Railscasts情节#196 和 Railscasts情节#在ASP.NET MVC3 197
I'm looking to do something similar to Railscasts Episode#196 and Railscasts Episode#197 in ASP.NET MVC3.
我有两个型号和订单
和的LineItem
和订单
至少包含一个的LineItem
。当用户正在创建的命令我将设置形式与一个条目的编辑为的LineItem
(我已经创建了一个EditorTemplate这样那样的正常工作。我会喜欢用jQuery动态添加更多的编辑为的LineItem
。
I have two models and Order
and LineItem
, and Order
contains at least one LineItem
. When the user is creating the order I will set the form up with one entry editor for the LineItem
(I've already created a EditorTemplate for this and that's working fine. I would like to use jQuery to dynamically add more editors for the LineItem
.
public class Order : EntityObject {
public string CustomerName { get;set; }
public EntityCollection<LineItem> LineItems { get;set; }
}
public class LineItem : EntityObject {
public long ProductId { get;set; }
public string Description { get;set; }
public double Quantity { get;set; }
}
什么是做到这一点的正确方法?
What is the proper way to do this?
推荐答案
pre-MVC3职位,但它仍然适用:
Pre-MVC3 posts, but it still applies:
<一个href=\"http://www.nickriggs.com/posts/using-aspnet-mvc-partial-views-for-dynamic-javascript-rendering/\"相对=nofollow>使用ASP.NET MVC局部视图动态的JavaScript渲染
<一个href=\"http://www.nickriggs.com/posts/render-your-model-with-client-side-jquery-templates-instead-of-asp-net-mvc-partial-views/\"相对=nofollow>渲染模型的客户端jQuery的模板而不是ASP.NET MVC局部视图
这篇关于如何编辑与ASP.NET MVC3嵌套模型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!