English 中文(简体)
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.

最佳回答

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




相关问题
WebForms and ASP.NET MVC co-existence

I am trying to make a WebForms project and ASP.NET MVC per this question. One of the things I ve done to make that happen is that I added a namespaces node to the WebForms web.config: <pages ...

Post back complex object from client side

I m using ASP.NET MVC and Entity Framework. I m going to pass a complex entity to the client side and allow the user to modify it, and post it back to the controller. But I don t know how to do that ...

Create an incremental placeholder in NHaml

What I want to reach is a way to add a script and style placeholder in my master. They will include my initial site.css and jquery.js files. Each haml page or partial can then add their own required ...

asp.net mvc automapper parsing

let s say we have something like this public class Person { public string Name {get; set;} public Country Country {get; set;} } public class PersonViewModel { public Person Person {get; ...

structureMap mocks stub help

I have an BLL that does validation on user input then inserts a parent(PorEO) and then inserts children(PorBoxEO). So there are two calls to the same InsertJCDC. One like this=>InsertJCDC(fakePor)...

ASP.NET MVC: How should it work with subversion?

So, I have an asp.net mvc app that is being worked on by multiple developers in differing capacities. This is our first time working on a mvc app and my first time working with .NET. Our app does not ...

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

热门标签