Well, what is a data source? In your action, it can take several default arguments, i.e.
ActionResult Search(string query, int startIndex, int pageSize) {...}
defaulted in the route settings, so startIndex is 0, and pageSize is (say) 20:
routes.MapRoute("Search", "Search/{query}/{startIndex}", new { controller = "Home", action = "Search", startIndex = 0, pageSize = 20 });
To split a pipe, you can easily use LINQ:
var page = source.Skip(startIndex).Take(pageSize);
(or do multiplication if you use "pageNumber" and not "startIndex")
With LINQ-toSQL, EF, etc. it should also build the database.
Then you can use the action links on the next page (etc.):
<%=Html.ActionLink("next page", "Search", new { query, startIndex = startIndex + pageSize, pageSize }) %>
Marc Gravell Jan 15 '09 at 10:11 2009-01-15 10:11
source share