寻呼asp.net的MVC
我有一个asp.net网站,我就在code翻阅使用背后:
i have an asp.net website where i do paging through on the code behind using:
PagedDataSource objPds = new PagedDataSource
{
DataSource = ds.Tables[0].DefaultView,
AllowPaging = true,
PageSize = 12
};
什么是做传呼的asp.net-MVC相当于最佳途径。我认为,这将在视图code实际上属于
what is the equivalent best way of doing paging for asp.net-mvc. I would think this would actually belong in the view code.
我只想定义它的页码自定义路线:
I would just define a custom route with the page number in it:
routes.MapRoute(
"Books", // Route name
"books/{page}", // URL with parameters
new {controller = "Books", action = "List", page = 1}
);
会给你这样的网址:
Will give you this kind of Url:
http://localhost/books/4/
然后在您的控制器动作,你得到这个页码:
Then in your controller action you get this page number:
public BooksController
{
public ActionResult List (int page)
{
/* Retrieve records for the requested page from the database */
return View ();
}
}
所以你的观点实际上不会知道当前页面的。它只会显示提供记录列表。
So your view will not actually be aware of the current page. It will just display a list of supplied records.
您还需要直接或者生成你的主人页面链接到各种网页无论是在这一观点。
You will also need to generate links to various pages either in this view directly or maybe in your master page.