Tuesday, May 27, 2008

Paging in ASP

//Execute the query and open the recordset
Rs.Open sql,Conn,3,1 //here 3 is cursor type and 1 is lock type. cursor type is static and lock type is readonly
If not(Rs.eof and Rs.bof) then

//initialize paging requirements
Pagesize = 5 //set page size to a variable
Page = request(“page”) //get the current page no into a variable
If Page = “” then Page = 1 //if this variable is null that means it is first page
Recordcount = Rs.recordcount //get no. of records in Rs
Rs.pagesize = Pagesize //assign page size to Rs
Rs.absolutepage = Page //current page no. assigned to Rs
TotalPages = Rs.Pagecount //get count of total no. of pages
Prev = Page – 1 //Previous page no. set here
Next = Page + 1 //Next page no. set here
Count = 1 //initialize count variable to 1

//open the while loop of the result set
While not Rs.eof and Count <= Pagesize //Here, looping is restricted to the page size that we have set
………………………..
//increment count variable
Count = Count + 1
//close loopWend

//At the bottom of the page, provide links for paging

No comments: