asp.net mvc - MVC3/CTP5/ViewModel/Master-Detail -


i trying wrangle in code first approach , have gap in understanding here. have collection of posts , files.

public class post { public post(){attachements = new list<files>();} [key] public int id{get;set;} public string title{get;set} public string body{get;set;} public virtual icollection<files> attachments {get;set;} }  public class file{ [key] public int id{get;set;} public string filename {get;set;} } 

and think have viewmodel down following

public class myview{ public post post {get;set;} public list<files> files {get;set;} public myview(post p, list<file> f){this.post = p; this.files = f;} 

everything works fine list , display ... when try create new post , files falls apart. i've tried using viewmodel not sure how add items list in view model.

i created view based on 'post' , have partial view uploads files , keeps list of them in hidden field can work, not sure if elegant solution.

could let me know if way off base ... hope start convo , collect responses helpful other noobs.

you'll need use list model binding features of mvc:

http://haacked.com/archive/2008/10/23/model-binding-to-a-list.aspx

for guide of how can work together:

http://blog.stevensanderson.com/2010/01/28/editing-a-variable-length-list-aspnet-mvc-2-style/


Comments

Popular posts from this blog

java - SNMP4J General Variable Binding Error -

windows - Python Service Installation - "Could not find PythonClass entry" -

Determine if a XmlNode is empty or null in C#? -