ASP Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreASP Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Stay one step ahead of the competition. Evaluate and give feedback on some of the hottest web development tools on the market today. Make your opinion heard! Click Here
  #1  
Old March 5th, 2003, 12:43 PM
SureShot SureShot is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2003
Posts: 6 SureShot User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Question How to Generate Pages - 1 | 2 | 3 etc...

I've looked around for a good while trying to figure out how to do this... and I need your help.

I have a web page that is dynamically generated and it display rows from a DB and the rows get to be in the 100s. I need to break it up into sections... but I'm not sure how to go about doing it.

What I'm wanting is something like this:

<< Previous 1 | 2 | 3 | 4 Next >>

(kindof like what is at the bottom of the forums here)

Any insight, code, direction would greatly be apprectiated!

--SureShot

Reply With Quote
  #2  
Old March 5th, 2003, 03:12 PM
mwtall mwtall is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2002
Posts: 5 mwtall User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Re: How to Generate Pages - 1 | 2 | 3 etc...

Quote:
Originally posted by SureShot
I've looked around for a good while trying to figure out how to do this... and I need your help.

I have a web page that is dynamically generated and it display rows from a DB and the rows get to be in the 100s. I need to break it up into sections... but I'm not sure how to go about doing it.

What I'm wanting is something like this:

<< Previous 1 | 2 | 3 | 4 Next >>

(kindof like what is at the bottom of the forums here)

Any insight, code, direction would greatly be apprectiated!

--SureShot



Try This:
First, request a page number from the querystring.
If Request.Querystring("Page") <> "" Then
Page = CInt(Request.Querystring("Page"))
Else
Page = 1
End If


Open your recordset.
RS.Open SqlQuery, DBConn, adOpenForwardOnly, adLockOptimistic

Set your page size to the value of n. This sets how many records to display on one page.
RS.PageSize = n

Set a variable to get the page count.
PageCount = RS.PageCount

Check to see if PageCount is greater than 0. If true, we will set the recordset page to the page number from the querystring.
If PageCount <> 0 Then
RS.AbsolutePage = Page
End If


Next, just build your NEXT & PREVIOUS links in the HTML.
<%
If Page <> 1 Then
%>
<a href="filename.asp?Page=<%= Page - 1 %>">Previous Link</a>
<%
End If

If Page < PageCount Then
%>
<a href="filename.asp?Page=<%= Page + 1 %>">Next Link</a>
<%
End If
%>


This generates Previous and Next links only.

Regards,
Matt

Last edited by mwtall : March 5th, 2003 at 03:18 PM.

Reply With Quote
  #3  
Old March 5th, 2003, 03:38 PM
SureShot SureShot is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2003
Posts: 6 SureShot User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Matt, thank you very much... I will try this. The "NEXT and PREVIOUS" will be enough I think.

Thanx a lot!

Reply With Quote
  #4  
Old March 6th, 2003, 02:41 PM
SureShot SureShot is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2003
Posts: 6 SureShot User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Well, I'm getting errors with this code.

I'm using a SQLOLEDB.... will that matter?

Reply With Quote
  #5  
Old March 6th, 2003, 03:33 PM
dotMATRIX dotMATRIX is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2003
Location: Cincinnati, Ohio
Posts: 25 dotMATRIX User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via ICQ to dotMATRIX
I doubt he meant for you to use his code literally. The key elements are in there, but you'll need to incorporate them into your existing code.

Code:
RS.PageSize = n
PageCount = RS.PageCount
RS.AbsolutePage = Page


Where "RS" is the recordset object. Anyway, you should be able to integrate those items into your existing object and make it all work.

dot

Reply With Quote
  #6  
Old March 6th, 2003, 03:54 PM
SureShot SureShot is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2003
Posts: 6 SureShot User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Talking

I didn't copy and paste his work literally... I did change all the variable and such to match my own and incorporated it into my code. I'm not a doof. ...but I guess you never can tell on the web.

this is the error generated:
Current Recordset does not support bookmarks. This may be a limitation of the provider or of the selected cursortype.

that is why I asked if SQLOLEDB would work with this...

Reply With Quote
  #7  
Old March 7th, 2003, 07:52 AM
mwtall mwtall is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2002
Posts: 5 mwtall User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
When you are opening your recordset...

Example:
RS.Open SqlQuery, DBConnection

What cursor are you using and what lock type? A static or forward-only cursor and an Optimistic lock should work and allow you to use Paging properties on the recordset.

There shouldn't be anything wrong with using SQLOLEDB, as long as you're setting your recordset to a ADODB.Recordset object type.

Use:
RS.Open SqlQuery, DBConnection, adOpenStatic OR adOpenForwardOnly, adLockOptimistic

If you don't have ADOVBS shortcuts....then use the values for the properties....

adOpenStatic = 0
adOpenForwardOnly = 1
adLockOptimistic = 3

Regards,
Matt

Reply With Quote
  #8  
Old March 7th, 2003, 10:26 AM
SureShot SureShot is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2003
Posts: 6 SureShot User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Well, I'm still getting the same error.

I'll work on it and see if I can get it to work with what you all have said.

Thanx y'all.

Last edited by SureShot : March 7th, 2003 at 10:34 AM.

Reply With Quote
  #9  
Old March 11th, 2003, 02:55 PM
SureShot SureShot is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2003
Posts: 6 SureShot User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Last straw!

------------------------------
*****
Got it... finally!
thanx for everyones help
*****

Last edited by SureShot : March 12th, 2003 at 02:23 PM.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreASP Programming > How to Generate Pages - 1 | 2 | 3 etc...


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway