Note that there are some explanatory texts on larger screens.

plurals
  1. POUsing two models in MVC application, one in a view and one in a partial
    primarykey
    data
    text
    <p>I am having some trouble. I have a view as below</p> <pre><code>@model IEnumerable&lt;Tipstr.Models.Posts&gt; &lt;div class ="mainC"&gt; &lt;div class = "leftContent"&gt; @Html.Partial("_LeaderboardPartial") &lt;/div&gt; &lt;div class = "rightContent"&gt; @foreach (var item in Model) { &lt;h1 class ="ptitle"&gt; @Html.DisplayFor(modelItem =&gt; item.title) &lt;/h1&gt; &lt;p class ="date"&gt; posted @Html.DisplayFor(modelItem =&gt; item.date) &lt;/p&gt; &lt;p class ="post"&gt; @Html.DisplayFor(modelItem =&gt; item.body) &lt;/p&gt; &lt;hr /&gt; } &lt;/div&gt; &lt;/div&gt; &lt;div class="Cpad"&gt; &lt;br class="clear" /&gt;&lt;div class="Cbottom"&gt;&lt;/div&gt;&lt;div class="Cbottomright"&gt; &lt;/div&gt; &lt;/div&gt; </code></pre> <p>And I have a partial, _LeaderboardPartial, as shown</p> <pre><code> @model IEnumerable&lt;Tipstr.Models.Leaderboard&gt; &lt;table id="pattern-style-a" summary="Meeting Results"&gt; &lt;thead&gt; &lt;tr&gt; &lt;th scope="col"&gt;Username&lt;/th&gt; &lt;th scope="col"&gt;Tipster Score&lt;/th&gt; &lt;/tr&gt; &lt;/thead&gt; &lt;tbody&gt; @foreach (var item in Model) { &lt;tr&gt; &lt;td&gt;@Html.DisplayFor(modelItem =&gt; item.userName)&lt;/td&gt; &lt;td&gt; @Html.DisplayFor(modelItem =&gt; item.score)&lt;/td&gt; &lt;/tr&gt; } &lt;/tbody&gt; &lt;/table&gt; </code></pre> <p>I can't seem to get it to work I think it has something to do with passing in one model from the layout and then another from the partial. How can I get around this? I get the following error:</p> <p>The model item passed into the dictionary is of type 'System.Collections.Generic.List<code>1[Tipstr.Models.Posts]', but this dictionary requires a model item of type 'System.Collections.Generic.IEnumerable</code>1[Tipstr.Models.Leaderboard]'.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload