10/06/2009

Display records/results across multiple pages in ASP

There is a simple way to show results across multiple pages if you use ADO. That is basically to divide the ADO record set in to multiple pages and show results in each page in the browser. A number of articles can be found regarding this in Web.

Few findings are worth noting

A recordset object has number of properties, methods and events.
Properties like absolutepage, cursorlocation, cursortype, pagecount, pagesize are required to do this job.

Say you have a recordset with 100 records
And you set recordset.pagesize = 20
That means your pagecount = 5(100/20)
Absolutepage indicates which page the cursor is locating in the recordset.

So set the recordset with following properties

with myrecordset

.cursorlocation=3

.cursortype=3

.pagesize=6

end with

then instantiate the recordset like following:

myrecordset.open sql datapovidername , , , adcmdtext

set the absolutepage property like this:

myrecordset.absolutepage=pg

'pg' is a variable used to store the page number retrieve at the time of user click on the page number.

Then its time to execute the recordset in a loop to retrieve the records

No comments:

Post a Comment