Ritz
Ritz

Reputation: 97

Please help me with ASP.NET MVC Paging error

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 definition 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.

Upvotes: 0

Views: 745

Answers (4)

Jonas Cannehag
Jonas Cannehag

Reputation: 391

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)

Upvotes: 2

Funka
Funka

Reputation: 4278

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!

Upvotes: 2

Jeremy Morgan
Jeremy Morgan

Reputation: 3372

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

Upvotes: 0

Ana Betts
Ana Betts

Reputation: 74652

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

Upvotes: 0

Related Questions