开发者

Asp MVC3 one to many Create and View

开发者 https://www.devze.com 2023-03-16 10:07 出处:网络
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\".

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

精彩评论

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