page spanning

This is a discussion on "page spanning" within the Classic ASP section. This forum, and the thread "page spanning are both part of the Program Your Website category.



Go Back   Webforumz.com > Main Forums > Program Your Website > Classic ASP

Notices


Closed Thread
 
LinkBack Thread Tools
  #1 (permalink)  
Old Aug 25th, 2004, 10:44
New Member
Join Date: Aug 2004
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
page spanning

I wonder if anyone could help me on this one. At the moment when data is displayed from the database it is listed all on one page, extending down as far as its needs to. What I would like to do is limit it to a set number of records and span it over a number of pages which can be selected.

Does anyone know how to do this easily?

Cheers

John

  #2 (permalink)  
Old Aug 25th, 2004, 11:12
Highly Reputable Member
Join Date: Jul 2003
Location: Ipswich, UK
Posts: 690
Thanks: 0
Thanked 0 Times in 0 Posts
sure thing dude, its called "paging", there are millions of examples out there, heres an easy one:

Code: Select all
<%
set conn = Server.CreateObject("ADODB.Connection")
conn.Open "DSN=AdvWorks"

set rs = Server.CreateObject("ADODB.Recordset")
rs.CursorLocation = 3  ' adUseClient
rs.Open "Select * from Employees", conn
rs.PageSize = 2
intPageCount = rs.PageCount

Select Case Request("Action")
	case "<<"
		intpage = 1
	case "<"
		intpage = Request("intpage")-1
		if intpage < 1 then intpage = 1
	case ">"
		intpage = Request("intpage")+1
		if intpage > intPageCount then intpage = IntPageCount
	Case ">>"
		intpage = intPageCount
	case else
		intpage = 1
end select
%>
<HTML>
<HEAD>
<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
<TITLE>ASP & ADO Paging</TITLE>
</HEAD>
<BODY bgColor=White text=Black>

<%
rs.AbsolutePage = intPage 
For intRecord = 1 To rs.PageSize 
	Response.Write "Record	number: " & intRecord & " " 
	Response.Write rs.Fields("FirstName") & " " 
	Response.Write rs.Fields("LastName") & "
" 
	rs.MoveNext
If rs.EOF Then Exit For 

Next

rs.Close
set rs = Nothing
conn.Close
set conn = nothing
%>
<form name="MovePage" action="default.asp" method="post">
<input type="hidden" name="intpage" value="<%=intpage%>">
<input type="submit" name="action" value="<<">
<input type="submit" name="action" value="<">
<input type="submit" name="action" value=">">
<input type="submit" name="action" value=">>">
Page: <%=Intpage & " of " & intpagecount%>
</form>
</BODY>
</HTML>
  #3 (permalink)  
Old Aug 26th, 2004, 10:40
New Member
Join Date: Aug 2004
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Nice one mate, thats really cool. Cheers!

John
  #4 (permalink)  
Old Aug 26th, 2004, 19:21
Reputable Member
Join Date: Aug 2003
Location: United Kingdom
Posts: 341
Thanks: 0
Thanked 0 Times in 0 Posts
or use Recordset.getRows to pull all the records into an array and Loop thru only the ones you want to display.
  #5 (permalink)  
Old Sep 3rd, 2004, 08:18
benbacardi's Avatar
Highly Reputable Member
Join Date: Feb 2004
Location: United Kingdom
Age: 20
Posts: 611
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to benbacardi Send a message via Skype™ to benbacardi
where in the code above smokie, do you determine how many records are shown on each page? maybe im just being dumb but.... ??:
  #6 (permalink)  
Old Sep 3rd, 2004, 10:49
Junior Member
Join Date: Aug 2003
Location: United Kingdom
Posts: 48
Thanks: 0
Thanked 0 Times in 0 Posts
<blockquote id="quote" class="ffs">quote:<hr height="1" noshade="noshade" id="quote" />Originally posted by benbacardi
where in the code above smokie, do you determine how many records are shown on each page? maybe im just being dumb but.... ??:<hr height="1" noshade="noshade" id="quote" /></blockquote id="quote">

rs.PageSize = 2

oh and don't use Request("intpage") - use Request.Querystring("intpage"). Otherwise expect random errors!!111!

/:P
Closed Thread

Tags
page, spanning

Thread Tools

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Best way to prevent access to page B except via page A? Donny Bahama PHP Forum 1 Apr 3rd, 2008 02:15
Green bar of colour at bottom of page gets bigger the more page is extended pixelgirl Web Page Design 1 Apr 1st, 2008 01:27
internal navigation, Linking from one page to a specific div in another page. Oak Web Page Design 5 Feb 8th, 2008 22:54
Linking an outside page back to previous framed page MJustison Starting Out 1 Oct 18th, 2007 17:49
A gap appears beween the Page Title and the Body Content of the page. sovereign6 Web Page Design 6 Dec 18th, 2006 19:14


All times are GMT. The time now is 06:17.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC8
© 2003-2008 Webforumz.com : All Rights Reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43