my index looks like this with page model which accepts list of objects
@model List<MyProject.Domain.Object>
@Html.Partial("PickDatePartial")
@Html.Partial("ObjectPartial", Model)
My problem is within this first partial page, cause this partial page accept not list but single @model MyProject.Domain.Object
How can I achive this, in this current situation index page cannot be rendered cause it expect to receive list of objects.
Thank you in advance.
Well, one quick and dirty thing you could to is pass the first object to
PickDatePartialThis is however not very clean. I would recommend creating a view model with two properties, 1) the whole list, 2) the one to be bound by
PickDatePartial:Then in your
Indexaction on your controller:You’ll need to change the type of the model on the
Indexview, of course. Now theIndexview looks like this: