views:

158

answers:

4

hello all,

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?)

<% if (Model.HasPreviousPage) { %>

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

A: 

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

Paul Betts
A: 

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
Jeremy Morgan
+2  A: 

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!

Funka
+2  A: 

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)

Jonas Cannehag