Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Incorporate paging in vbscript Data Class file

Status
Not open for further replies.

toysyn

Programmer
May 19, 2003
6
US
I am new to vbscript classes, and use the following code to centralize data access in my application:

NOTICE THAT THE CLASS RETURNS A GETROWS ARRAY OF RECORDS

I am trying to find a way to centralize paging from within the class so that i can create one page for both listing records and search results using the pager.

How could I incorporate the follwing paging function in the Data class to work on any page?


QUERY LINE:
’arrArray = ExecuteSQL(strSQL)

PAGING VARIABLES:
dim iStart, iOffset, iStop, iRows, iCols, iRowLoop, iColLoop

iStart = Request.querystring("Start")
iOffset = Request.Querystring("Offset")

if Not IsNumeric(iStart) or Len(iStart) = 0 then
iStart = 0
else
iStart = CInt(iStart)
end if

if Not IsNumeric(iOffset) or Len(iOffset) = 0 then
iOffset = 15
else
iOffset = Cint(iOffset)
end if

iRows = UBound(cntArr, 2)
iCols = UBound(cntArr, 1)

If iRows > (iOffset + iStart) Then
iStop = iOffset + iStart - 1
Else
iStop = iRows
end If

RECORD OUTPUT:
For iRowLoop=iStart to iStop
'response write rowdata
For iColloop=0 to iCols
' response write coldata
next
next

PAGING:
Function pager 'for getrows
iNumPages = Int((iRows + iOffset - 1) / iOffset)
for iPage = 1 to iNumPages
iPageStart = (iPage - 1) * iOffset
iPageStop = iPageStart + iOffset - 1 ' -- change this line
if(iPageStop > iRows) then
iPageStop = iRows
end if
If (iPage > 1) Then response.write " | " end if
if(iPageStart = iStart) then
Response.Write " <span class=stxtb>" & (iPageStart+1) & "-" & (iPageStop+1) & "</span>"
else
Response.Write " <a href="&getpage&"?Start=" & iPageStart & _
"&Offset=" & iOffset & "><span class=stxt1>" & (iPageStart+1) & "-" & (iPageStop+1) & "</span></a>"
end if
next
end Function

Any help is greatly appreciated
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top