如何编辑与ASP.NET MVC3嵌套模型 [英] How to edit nested models with ASP.NET MVC3

查看:206
本文介绍了如何编辑与ASP.NET MVC3嵌套模型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望做类似的东西来 Railscasts情节#196 Railscasts情节#在ASP.NET MVC3 1​​97

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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆