我在这里收到以下错误:
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]'.
我不知道我错在哪里。这是来自RoomTypecontroller的GetMenu方法:
'public ActionResult GetMenu()
{
DBContext.Current.Open();
var model =RoomType.SelectAll();
DBContext.Current.Close();
return PartialView(model);
}'
这是我的获取菜单视图:
@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>
}
答案 0 :(得分:0)
其实我不知道你的RoomType.SelectAll()
做了什么,但我想它会以任何方式返回List<object>
尝试它应该有效:
var model = RoomType.SelectAll().Cast<RoomType>();