Reputation: 187
I have one Viewpage where I inherit List version of my model class to show a list of products. Now on the same page I want to create a form for which I need to use my model class properties. As I'm using a List version of model class, I'm not being able to get the properties without iterating the items in Model.
I tried creating an UserControl inheritting the model class itself and use <%Html.RenderPartial("UserControl"); %>
in my list class. But it gives runtime error.
How to avoid this situation?? Please help.
Upvotes: 0
Views: 277
Reputation: 24882
No you can do it by creating a composite model object containg your first model and your second one
In your page directive: ViewPage<YouCompositeModelType>
in your page: <% Html.RenderPartial("YourPartialViewName", Model.YourSecondModelObject); %>
Upvotes: 2