Asp.net mvc 传递到字典的模型项的类型为“System.Collections.Generic.List ErroR”
我在这里得到以下错误:Asp.net mvc 传递到字典的模型项的类型为“System.Collections.Generic.List ErroR”,asp.net-mvc,asp.net-mvc-3,Asp.net Mvc,Asp.net Mvc 3,我在这里得到以下错误: Line 45: <tr> Line 46: <td width="15%" valign="top"> Line 47: @{Html.RenderAction("GetMenu","RoomType");} Line 48: </td> Line 49:
Line 45: <tr>
Line 46: <td width="15%" valign="top">
Line 47: @{Html.RenderAction("GetMenu","RoomType");}
Line 48: </td>
Line 49: <td valign="top"
'The model item passed into the dictionary is of type
'System.Collections.Generic.List`1[System.Object]', but this dictionary requires a model item of type 'System.Collections.Generic.IEnumerable`1[LicentaTest.Models.RoomType]'.
这是我的“获取菜单”视图:
@model IEnumerable<LicentaTest.Models.RoomType>
@using LicentaTest.Models
<script type="text/javascript">
$(function () {
$("#categories").addClass("ui-widget");
$("a", "#categories").button().width(200);
});
</script>
<ul id="categories">
@foreach (var tipcamera in Model)
{
<li>@Html.ActionLink(tipcamera.Room_Type,"Browse","RoomType",new{RoomType=tipcamera.Room_Type},null)
</li>
}
事实上,我不知道您的房间类型。SelectAll可以做什么,但我想它会以任何方式返回一个列表。试试这个,它应该可以工作:
var model = RoomType.SelectAll().Cast<RoomType>();
RoomType的返回类型是什么。SelectAll
var model = RoomType.SelectAll().Cast<RoomType>();