我遇到了一些麻烦。我的看法如下
@model IEnumerable<Tipstr.Models.Posts>
<div class ="mainC">
<div class = "leftContent">
@Html.Partial("_LeaderboardPartial")
</div>
<div class = "rightContent">
@foreach (var item in Model) {
<h1 class ="ptitle">
@Html.DisplayFor(modelItem => item.title)
</h1>
<p class ="date">
posted @Html.DisplayFor(modelItem => item.date)
</p>
<p class ="post">
@Html.DisplayFor(modelItem => item.body)
</p>
<hr />
}
</div>
</div>
<div class="Cpad">
<br class="clear" /><div class="Cbottom"></div><div class="Cbottomright">
</div>
</div>
我有一个部分,_LeaderboardPartial,如图所示
@model IEnumerable<Tipstr.Models.Leaderboard>
<table id="pattern-style-a" summary="Meeting Results">
<thead>
<tr>
<th scope="col">Username</th>
<th scope="col">Tipster Score</th>
</tr>
</thead>
<tbody>
@foreach (var item in Model) {
<tr>
<td>@Html.DisplayFor(modelItem => item.userName)</td>
<td> @Html.DisplayFor(modelItem => item.score)</td>
</tr>
}
</tbody>
</table>
我似乎无法让它工作我认为它与从布局中传递一个模型然后从局部传递另一个模型有关。我怎样才能解决这个问题?我收到以下错误:
传入字典的模型项的类型为“System.Collections.Generic.List 1[Tipstr.Models.Posts]', but this dictionary requires a model item of type 'System.Collections.Generic.IEnumerable
1[Tipstr.Models.Leaderboard]”。