开发者

Asp MVC3 one to many Create and View

I can not figure out a way to create one to many model in a single view, any help 开发者_StackOverflow中文版?


In your model, include the "many".

Example

public class Parent { public int ParentId; }

public class Child { public int ChildId; public int ParentId; }

Then create a View Model

public class ParentViewModel { Parent p; IEnumerable c; }

Then iterate with a foreach(var child in Model.c) on the View

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜