0

我在这里收到以下错误:

        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>


        }

4

1 回答 1

0

实际上我不知道你在RoomType.SelectAll()做什么,但我想它会以List<object>任何方式返回,尝试一下它应该可以工作:

var model = RoomType.SelectAll().Cast<RoomType>();
于 2012-05-07T14:29:04.660 回答