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
精彩评论