我正在用mvc3开发一个简单的项目。创建了两个模型Customer & call。在CustomerController中,我使用PagedList进行分页。我在客户的索引视图上显示了分页。我想在客户索引视图上显示最后5个记录呼叫列表。我为Call的索引视图创建了局部视图。我在客户索引页面上使用了调用的部分视图,如下所示--
@Html.Partial("IndexCallPartial")但它在选择客户索引页面后显示错误。错误如下-
The model item passed into the dictionary is of type 'PagedList.PagedList`1[graceCRM.Models.Customer]', but this dictionary requires a model item of type 'graceCRM.Models.Call'.如何解决这个问题?
发布于 2012-06-27 14:25:01
错误消息非常简单明了。在其中调用Html.Partial帮助器的视图被强类型化为PagedList<Customer>类。默认情况下,@Html.Partial("IndexCallPartial")等同于@Html.Partial("IndexCallPartial", Model)。这意味着它是将被传递给partial的PagedList<Customer>的一个实例。但是你的partial并不需要这样的实例。错误消息会告诉您它所期望的实例。
因此,要解决此问题,您需要传递正确的实例:
@Html.Partial("IndexCallPartial", some_instance_of_the_correct_type_the_partial_expects)https://stackoverflow.com/questions/11220012
复制相似问题