I must be stupid to not be able to follow simple destructions or something...but then again I have found often the destructions assume knowledge from previous tutorials and examples from x years ago, that I may not have found.
This seems deceptively simple, but I am obviously missing something.
Never tried working with a partial view before.
I have set up a partial view with the following controller returning the correct records:
Tested it and it works great.
public IActionResult _partialJobHistory(
var jobs = from j in _context.Job
.Include(j => j.Site)
.Include(j => j.WaterBody)
.Where(j => j.Site.SiteID == id)
.OrderByDescending(j => j.BookingDate)
Now I want to merge it into my Site Details view.
In Site.Details I have added the following code to include the partial view and pass in the siteID from the details view (I think).
Which from all the reading I have done follows:
|MvcHtmlString Html.Partial(string partialViewName,object model) ||Renders the partial view content in the referred view. Model parameter passes the model object to the partial view. |
However I am obviously missing something despite studying three different tutorials and msdn.
I am getting an error on loading the details page of:
I cant see from the reading what is wrong?
InvalidOperationException: The model item passed into the ViewDataDictionary is of type 'System.Int32', but this ViewDataDictionary instance requires a model item of type 'System.Collections.Generic.IEnumerable`1[EVA.Models.Job]'.
I don't fully understand why if I manually enter the address as, http://localhost:62233/Jobs/_partialJobHistory/36 it works exactly as desired. So isn't this what I am passing to the partial view in the code? Why isn't it?