Error while trying to render a partial view in a view

Asked

Viewed 100 times

1

I have a View(cshtml) and I need to call a partialView. This Partial is a table with the logs of that Sale, which will be viewed in tabular format at the bottom of the View. The problem is that when I try to open the View(Index) I get this error:

The model item passed into the Dictionary is of type 'System.Int32', but this Dictionary requires a model item of type 'System.Collections.Generic.Ienumerable`1[Subscriptioncenter.Core.Domain.Logs.Logalteracao]'.

How do I fix it?

This is my html where to "register" the Partial View

<div class="margin-40-b">
    <p>@Html.Partial("_LogAlterarMarkup", Model.CustomerId)</p>
</div>

I’ve done it like this:

<p>@Html.Partial("_LogAlterarMarkup")</p>

and so

<p>@Html.Partial("_LogAlterarMarkup", Model.CustomerId)</p>

and also so

<p>@Html.Partial("_LogAlterarMarkup", Model.OrderId)</p>

OBS: A partial view is another Model(Log)

1 answer

1

The answer is in your error message:

The model item passed into the Dictionary is of type 'System.Int32', but this Dictionary requires a model item of type 'System.Collections.Generic.Ienumerable`1[Subscriptioncenter.Core.Domain.Logs.Logalteracao]'.

You’re going to Partial one Int32 but in it is expected a IEnumerable<LogAlteracao>, passing the correct type will probably be rendered correctly, if there are no errors in the partial, clear-cut.

  • And how do I do that? This is not the View model, how do I take this model and step?

  • @pnet how is the model expected in _Logalterarmarkup.cshtml? If possible post in the question.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.