开发者

How to bind POST data with a model that contains multiple models (ie: a model containing multiple custom objects)?

开发者 https://www.devze.com 2023-01-23 08:11 出处:网络
I have a parent View that uses a few partial views. Each partial view has its own custom model. The parent View is a model containing each of the partial view\'s model. In other words this parent View

I have a parent View that uses a few partial views. Each partial view has its own custom model. The parent View is a model containing each of the partial view's model. In other words this parent View model is NOT flat.

How do i get POST data to bind with the parent's model object? Do i have to write a custom model binder?

Update I'm not binding to a collection of objects of the same type (ie: a collection of uploaded files). I'm binding to object th开发者_JAVA百科at contains multiple of objects. For example:

   public class ProductViewModel { 
        public ProductTreeViewModel TreeView; 
        public ProductDetails Details; 
        public ProductBreadcrumb BreadCrumb; 
   }


See my answer here: How to handle `PartialRender` Models?

Essentially it is all about

<input type="text" name="Doors[<%: i %>].FrontFile" id="Doors[<%: i %>].FrontFile">

Does that help?

0

精彩评论

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