0
我碰到下面的錯誤在這裏:傳遞到字典的模型項的類型爲「System.Collections.Generic.List錯誤
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]'.
我不知道我錯了。這是從我的使用getMenu方法RoomTypecontroller:
'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>
}
是什麼RoomType.SelectAll的返回類型() – Shyju