English 中文(简体)
输入字典的模型是类型系统。
原标题:The model item passed into the dictionary is of type System.Collections.Generic.Lis

指数观点给我这个非常令人厌恶的错误。 任何人都能够告诉我什么事情要做。

Error: The model item passed into the dictionary is of type System.Collections.Generic.List1[MvcApplication13.Models.Groups] , but this dictionary requires a model item of type MvcApplication13.Helpers.PaginatedList1[MvcApplication13.Models.Groups] .

public ActionResult Index(int? page) { const int pageSize = 10; var group =from p in _db.Groups orderby p.int_GroupId select p;

      var paginatedGroup = group.Skip((page ?? 0) * pageSize).Take(pageSize).ToList();
      return View(paginatedGroup);            
    }

观点:

>" %>

Index

<h2>Index</h2>

<table>
    <tr>
        <th></th>
        <th>
            int_GroupId
        </th>
        <th>
            vcr_GroupName
        </th>
        <th>
            txt_GroupDescription
        </th>
        <th>
            bit_Is_Deletable
        </th>
        <th>
            bit_Active
        </th>
        <th>
            int_CreatedBy
        </th>
        <th>
            dtm_CreatedDate
        </th>
        <th>
            int_ModifiedBy
        </th>
        <th>
            dtm_ModifiedDate
        </th>
    </tr>

<% foreach (var item in Model) { %>

    <tr>
        <td>
            <%= Html.ActionLink("Edit", "Edit", new { id=item.int_GroupId }) %> |
            <%= Html.ActionLink("Details", "Details", new { id=item.int_GroupId })%> |
            <%= Html.ActionLink("Delete", "Delete", new { id=item.int_GroupId })%>
        </td>
        <td>
            <%= Html.Encode(item.int_GroupId) %>
        </td>
        <td>
            <%= Html.Encode(item.vcr_GroupName) %>
        </td>
        <td>
            <%= Html.Encode(item.txt_GroupDescription) %>
        </td>
        <td>
            <%= Html.Encode(item.bit_Is_Deletable) %>
        </td>
        <td>
            <%= Html.Encode(item.bit_Active) %>
        </td>
        <td>
            <%= Html.Encode(item.int_CreatedBy) %>
        </td>
        <td>
            <%= Html.Encode(String.Format("{0:g}", item.dtm_CreatedDate)) %>
        </td>
        <td>
            <%= Html.Encode(item.int_ModifiedBy) %>
        </td>
        <td>
            <%= Html.Encode(String.Format("{0:g}", item.dtm_ModifiedDate)) %>
        </td>
    </tr>

<% } %>

</table>
>>", "UpcomingDinners", new { page = (Model.PageIndex + 1) }) %>
<p>
    <%= Html.ActionLink("Create New", "Create") %>
</p>

最佳回答

You lost some data when you pasted your code. This is what I think you meant to paste: View

<%@ Page Title="" Language="C#" 
  MasterPageFile="~/Views/Shared/Site.Master" 
 Inherits="System.Web.Mvc.ViewPage<MvcApplication13.Helpers.PaginatedList<MvcApplication13.Models.Groups>>" %>

如果是这样的话,你们的法典应当看上去类似(例如,创立一个新例子,以证明PaginatedList阶级:

public ActionResult Index(int? page) {

    const int pageSize = 10;

    var upcomingDinners = dinnerRepository.FindUpcomingDinners();
    var paginatedDinners = new PaginatedList<Dinner>(upcomingDinners, page ?? 0, pageSize);

    return View(paginatedDinners);
}

rel=“nofollow noreferer” http://nerddinnerbook.s3.amazonaws.com/Part8.htm

问题回答

暂无回答




相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Transaction handling with TransactionScope

I am implementing Transaction using TransactionScope with the help this MSDN article http://msdn.microsoft.com/en-us/library/system.transactions.transactionscope.aspx I just want to confirm that is ...

System.Web.Mvc.Controller Initialize

i have the following base controller... public class BaseController : Controller { protected override void Initialize(System.Web.Routing.RequestContext requestContext) { if (...

Microsoft.Contracts namespace

For what it is necessary Microsoft.Contracts namespace in asp.net? I mean, in what cases I could write using Microsoft.Contracts;?

Separator line in ASP.NET

I d like to add a simple separator line in an aspx web form. Does anyone know how? It sounds easy enough, but still I can t manage to find how to do it.. 10x!

热门标签