How to do effective paging in Classic ASP?

2019-04-16 15:47发布

问题:

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?

回答1:

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



回答2:

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



回答3:

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.