Groups | Blog | Home
all groups > inetserver asp db > december 2004 >

inetserver asp db : Navigate pages?


Targa
12/22/2004 12:19:16 AM
I currently use a pulldown which holds all customer names. When a customer
is selected, it takes the user to a detail page.
Basically using the autonumber ID field.

Select * from myTable where ID = ID

I would like to allow the user to navigate to previous or next records from
the detail page.
ie << Previous Record | Next Record >>

How can I do this?

Gérard Leclercq
12/22/2004 6:34:13 AM
What you want to dio calls PAGING. Here an exemple. You can set the variable
to 1 if you only wish to see 1 record.
http://www.juicystudio.com/tutorial/asp/paging.asp

Gérard Leclercq
12/22/2004 6:39:06 AM
A second way is:



Select * from table where ID=ID

Select case Request.Form("action")

Case "N"
MoveNext

Case "P"
MovePrevious

Case Else
'do nothing
End Select

Show Record

McKirahan
12/22/2004 10:53:43 AM
[quoted text, click to view]

Are the names in the pulldown in order by ID or by name?

If there not in order by ID then you can use an array and a dictionary to
identify which is the next and previous relative to each ID.

<select name="pick">
<option value="11">Joe
<option value="22">Mary
<option value="33">Alan
<option value="44">Billy
</select>

The values above represent the ID of the name.

Dim intIDX
Dim arrNAM(3,1)
arrNAM(0,0) = "Alan"
arrNAM(0,1) = 33
arrNAM(1,0) = "Billy"
arrNAM(1,1) = 44
arrNAM(2,0) = "Joe"
arrNAM(2,1) = 11
arrNAM(3,0) = "Mary"
arrNAM(3,1) = 22
Dim intNAM
intNAM
Dim strNAM

Dim objDIC
Set objDIC = CreateObject("Scripting"Dictionary")
objDIC.Add "Joe", 2
objDIC.Add "Mary", 3
objDIC.Add "Alan", 0
objDIC.Add "Billy", 1

So that is "Joe" is selected then you can determine that "Previous" is
"Billy" and "Next" is "Mary".

Dim strSEL
strSEL = Request.Form("pick") '= Joe
intNAM = objDic.Item(strSEL) '= 2
If intNAM > 0 Then
strNAM = arrNAM(intNAM-1,0) '= Prev = Billy
intIDX = arrNAM(intNAM-1,1)
ElseIf intNAM < UBound(arrNAM) Then
strNAM = arrNAM(intNAM+1,0) '= Next = Mary
intIDX = arrNAM(intNAM+1,1)
Else
strNAM = "BOF or EOF"
intIDX = -1
End If

The array and dictionary are built at the same time the options are.

To dynamically enlarge the array as it is built, use:

Dim arrNAM()
Do
ReDim Preserve arrNAM(intNAM)
arrNAM(intNAM,0) = objRST("Name").Value
arrNAM(intNAM,1) = objRST("ID").Value
intNAM = intNAM + 1
Loop

jeff.nospam NO[at]SPAM zina.com
12/22/2004 11:03:42 PM
On Wed, 22 Dec 2004 00:19:16 -0600, "Targa"
[quoted text, click to view]

Paging recordsets:

http://www.aspfaq.com/show.asp?id=2120

AddThis Social Bookmark Button