开发者

Please help me with ASP.NET MVC Paging error

开发者 https://www.devze.com 2022-12-12 11:47 出处:网络
I am getting the following error in my mvc application when I am doing the paging functionality CS1061: \'System.Collections.Generic.IEnumerable\' does not contain a definitio开发者_如何学JAVAn for \

I am getting the following error in my mvc application when I am doing the paging functionality

CS1061: 'System.Collections.Generic.IEnumerable' does not contain a definitio开发者_如何学JAVAn for 'HasPreviousPage' and no extension method 'HasPreviousPage' accepting a first argument of type 'System.Collections.Generic.IEnumerable' could be found (are you missing a using directive or an assembly reference?)

please tell me what to do and what is that Model.


This reminds me of the PaginatedList<T> class found in the Conery et al MVC 1.0 Wrox book... (And probably also found in the NerdDinner app.) I actually have this book right here next to me and have this section tabbed. And sure enough they have a property called HasPreviousPage, which leads me to guess this is what you are working with? It is in Chapter 1, which is a free download. (Google for it.) I highly recommend taking a look at this chapter, or at least this section, as there are many other helpful suggestions and tips to be found!

Best of luck!


I think that you may be missing a namespace import.

Is HasPreviousPage a method or a property? If it is a helpermethod on the type of list you are returning then you need to import that namespace in your aspx file (or in the web.config to reflect on all pages)


You need to change the controller to use Paging, check out http://blogs.embarcadero.com/johnk/2009/04/02/38871 for more info

EDIT: To clarify, so somewhere in the Controller, you're gonna see something to the effect of "return View(someModelObject)" - you need to use PaginationHelper.AsPagination here to turn someModelObject into a pageable object


There are a few possibilities here:

First off, Model is your object, or class. HasPreviousPage is a method or function in Model.

Here are some possibilities:

  1. Model is not defined because the file is not included in the page
  2. HasPreviousPage does not exist as a method
  3. HasPreviousPage is actually a property and needs more information to extract data (as tster is saying)
  4. The signature for HasPreviousPage is incorrect. You are sending too much, or not enough data.

My guess is it's either a boolean property, or a method that returns a boolean. Either way the compiler has no idea what to do with it, so you need to track it down. Try doing a find in your solution for "HasPreviousPage". See if it's been referenced anywhere, or where it is located.

Ctrl + F
Find What: 
HasPreviousPage
Look In:
Entire Solution
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号