开发者

asp.net MVC3 ActionResult multiple models and a view

开发者 https://www.devze.com 2023-04-13 04:07 出处:网络
What I am trying to do using asp.net MVC3: -User selects a Category from a list of Categories. -The SubCategories page then displays a list of images found to represent that Parent Category as well

What I am trying to do using asp.net MVC3:

-User selects a Category from a list of Categories.

-The SubCategories page then displays a list of images found to represent that Parent Category as well as the list of SubCategories.

I run into the need for multiple models because the "Category Images" are associated with Category and not the "SubCategory model". Yes I realize this seems like it has been asked 开发者_如何学Gomany times before but the syntax is still foreign to a noob like me. What goes where?

I got the Category -> Html.Actionlink to the controller to return a list of SubCategories part... but even if I did some left join to get category and list of images as well, how would I get those into the same view as the list of subcategories?

Update Found this posting:

http://francorobles.wordpress.com/2011/05/03/returning-multiple-models-in-1-view-in-asp-net-mvc3/

Question: Is that a valid approach? My intellisense suggests no.


In cases like this you need "view models", i.e. view-specific models that have all the data your view needs.

0

精彩评论

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

关注公众号