views:

2036

answers:

4

I'm trying to page a table, and while I have paging already working, it displays every page in a single line along with Previous/Next links, causing the HTML page to break if there are a lot of results (which often there are).

What I'd like to do is display the pages in batches of 10, e.g. 1...10, if you're on page 10 and click "Next" then it changes to 11-20, and so on. How should I go about doing this?

A: 

If you were using MySQL, you can do the pagination right in the sql, something like this:

SELECT ...
FROM
WHERE
LIMIT pagenum*pagesize, (pagenum+1)*pagesize

edited: I first thought that the above sql was for sqlserver.

Tiago
Isn't that a MySQL'ism?
Kev
@Kev: You got me.. Now I´m not sure... it's been ages since I programmed using classic asp and sqlserver.
Tiago
A: 

This article is about paging using SQL Server 2000. Classic ASP is a little slow so I advise you not handling the paging there. Its just not fun

Perpetualcoder
A: 

One solution would be to let the client-side do the paging. If the table is not too horribly long, this would work quite well. We use the following jQuery plugin: http://sprymedia.co.uk/dataTables/example_multiple_tables.html

cdeszaq
+3  A: 

Wayne I would recommend you have a look at ajaxed asp library. It is a still active classic ASP project which provides generic paging (for all kind of data structures) and also uses the paging mechanism within its Datatable control.

That control easily allows you to create a table with just a SQL Query. Similar to asp.net's Datagrid. Fully AJAX as well.

Check the datatable examples and you will see the batch paging and more... everything fully configureable.

Supported DBs are MySQL, sqlite, MS Access, MS Sqlserver, Oracle

Michal
WOW. I will definitely check that out - it looks really neat and I was using some Rails-like best practices for my application anyway.
Wayne M