开发者

asp.net mvc: Paging - Setting Prev/Next page values in ActionLinks?

I'm trying to implement some simple paging, based on How do I do pagination in ASP.NET MVC?

The paging works fine.

However, I'm now trying to create previous and next links, but can't figure out how to access the params:

My route looks like:

  routes.MapRoute(
      "Name",
      "Controller/ActionName/{pageID}",
      new { controller = "Controller", action = "ActionName" , pageID = 0 },
      new { pageID = @"\d*"}
      );

And my next link looks like:

   <%=Html.ActionLink("next page", "ActionName", "Controller", new {pageID = pageID + 1 }, null) %>

The error I get is:

 Compiler Error Message: CS0103: The name 'pageID' does not exist in the current context
开发者_StackOverflow

How should I create the Prev/Next links (or, in this case, just the next)?


The error is occurring on the second PageID in

new {pageID = pageID + 1 }, ...

If you want to reference pageID in this way, you have to pass it in as part of your model.

Have a look at the following tutorial:

NerdDinner Step 8: Paging Support
http://nerddinnerbook.s3.amazonaws.com/Part8.htm

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜