开发者

Modelbinding when the model is repeated on the page

开发者 https://www.devze.com 2023-03-17 00:43 出处:网络
I can\'t believe this is so hard to find but... I have a model that will be repeated multiple times on a page. By default it names the fields the same on both models so it doesn\'t seem to bind prope

I can't believe this is so hard to find but...

I have a model that will be repeated multiple times on a page. By default it names the fields the same on both models so it doesn't seem to bind properly. How do I make it so I can use the same model multiple times?

Basic context of the issue: Picture having a user that can add unlimited contacts on the same page. The contact fields are based on a model (name address phone ect), and I just enumerate through that model to show each field for each contact. The first iterat开发者_StackOverflowion works fine, but after the first contact, nothing seems to get passed back to the model on post.

Thanks ahead of time.


Please look at following blog posts
http://blog.stevensanderson.com/2010/01/28/editing-a-variable-length-list-aspnet-mvc-2-style/
http://zahidadeel.blogspot.com/2011/05/master-detail-form-in-aspnet-mvc-3-ii.html
http://ivanz.com/2011/06/16/editing-variable-length-reorderable-collections-in-asp-net-mvc-part-1/
http://blog.stevensanderson.com/2010/07/12/editing-a-variable-length-list-knockout-style/

0

精彩评论

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

关注公众号