Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   ASP General (http://www.velocityreviews.com/forums/f65-asp-general.html)
-   -   asp Pagination Help (http://www.velocityreviews.com/forums/t799266-asp-pagination-help.html)

Kelvin 07-27-2005 07:40 AM

asp Pagination Help
 
Hi All,

I don't know how to reuse the following source code, please comment.

iTtlTemp = iTtlNumItems \ iNumPerPage <--- How to get value
iDBLocTemp = iDBLoc \ iNumPerPage <--- How to get value
iDBLoc <--- How to get value

------------------
' Print the numbers in between. Print them out in sets of 10.
iA = ( iDBLocTemp \ iNumPerPage ) * iNumPerPage
iB = ( iDBLocTemp \ iNumPerPage ) * iNumPerPage + iNumPerPage
For x = iA To iB
iTemp = (x * iNumPerPage)
if (iTemp < iTtlNumItems) Then ' takes care of extra numbers
after the overall final number
if (iDBLoc = iTemp) Then
Response.Write " <B>[" & x+1 & "]</B>"
Else
Response.Write " " & sURLBeg & (x * iNumPerPage) & """>" & x+1
& "</A>"
End if
Else
Exit For
End if
Next
---------------------



Whole Source Code

Sub PrintRecordsetNav( iNumPerPage, adodbConnection, adodbCommand,
sTable, sURL, sQuerystring )

Dim iTtlNumItems, iDBLoc, sSqlTemp, iTtlTemp
Dim iDBLocTemp, sURLBeg, iA, iB, x, iTemp, rsObj

iDBLoc = CInt(Request("iDBLoc"))
iTtlNumItems = CInt(Request("iTtlNumItems"))
' Get ttl num of items from the database if it's Not already In
the QueryString
if (iTtlNumItems = 0) Then
Set rsObj = Server.CreateObject("ADODB.Recordset")
sSqlTemp = "SELECT COUNT(*) FROM " & sTable
adodbCommand.CommandText = sSqlTemp
rsObj.Open adodbCommand
if Not(rsObj.EOF) Then
iTtlNumItems = rsObj(0)
End if
rsObj.Close
Set rsObj = Nothing
End if
iTtlTemp = iTtlNumItems \ iNumPerPage ' this is the number of
numbers overall (use the "\" To return int)
iDBLocTemp = iDBLoc \ iNumPerPage ' this is which number we are
currently On (use the "\" To return int)
if (sQuerystring <> "") Then
sURLBeg = "<A href = """ & sURL & "?" & sQuerystring &
"&iTtlNumItems=" & iTtlNumItems & "&iDBLoc="
Else
sURLBeg = "<A href = """ & sURL & "?iTtlNumItems=" &
iTtlNumItems & "&iDBLoc="
End if

'***** BEGIN DISPLAY *****
' Print the "Previous"
if (iDBLoc <> 0) Then
Response.Write sURLBeg & (iDBLoc - iNumPerPage) &
""">Previous</A> "
End if
' Print the <<
if (iDBLocTemp >= iNumPerPage) Then
Response.Write sURLBeg & (( iDBLocTemp \ iNumPerPage ) *
iNumPerPage ^ 2) - (iNumPerPage * 9) & """><<</A> "
End if

' Print the numbers in between. Print them out in sets of 10.
iA = ( iDBLocTemp \ iNumPerPage ) * iNumPerPage
iB = ( iDBLocTemp \ iNumPerPage ) * iNumPerPage + iNumPerPage
For x = iA To iB
iTemp = (x * iNumPerPage)
if (iTemp < iTtlNumItems) Then ' takes care of extra numbers
after the overall final number
if (iDBLoc = iTemp) Then
Response.Write " <B>[" & x+1 & "]</B>"
Else
Response.Write " " & sURLBeg & (x * iNumPerPage) & """>" & x+1
& "</A>"
End if
Else
Exit For
End if
Next

' Print the >>
if (iTtlTemp > iDBLocTemp) Then
if ((iDBLocTemp + iNumPerPage) <= iTtlTemp) Then
Response.Write " " & sURLBeg & (( iDBLocTemp \ iNumPerPage ) *
iNumPerPage + iNumPerPage ) * iNumPerPage & """>>></A> "
End if
End if
' Print the "Next"
if ((iDBLoc + iNumPerPage) < iTtlNumItems) Then
Response.Write " " & sURLBeg & (iDBLoc + iNumPerPage) &
""">Next</A>"
End if
'***** End DISPLAY *****

End Sub
'***************************************
' ****************************************

Steven Burn 07-27-2005 10:43 AM

Re: asp Pagination Help
 
Const iNumPerPage = 20

or

iNumPerPage = Request.QueryString("inpp")

--
Regards

Steven Burn
Ur I.T. Mate Group
www.it-mate.co.uk

Keeping it FREE!
"Kelvin" <kelvinweb@gmail.com> wrote in message
news:db7965c.0507262340.5b8ac0c8@posting.google.co m...
> Hi All,
>
> I don't know how to reuse the following source code, please comment.
>
> iTtlTemp = iTtlNumItems \ iNumPerPage <--- How to get value
> iDBLocTemp = iDBLoc \ iNumPerPage <--- How to get value
> iDBLoc <--- How to get value
>
> ------------------
> ' Print the numbers in between. Print them out in sets of 10.
> iA = ( iDBLocTemp \ iNumPerPage ) * iNumPerPage
> iB = ( iDBLocTemp \ iNumPerPage ) * iNumPerPage + iNumPerPage
> For x = iA To iB
> iTemp = (x * iNumPerPage)
> if (iTemp < iTtlNumItems) Then ' takes care of extra numbers
> after the overall final number
> if (iDBLoc = iTemp) Then
> Response.Write " <B>[" & x+1 & "]</B>"
> Else
> Response.Write " " & sURLBeg & (x * iNumPerPage) & """>" & x+1
> & "</A>"
> End if
> Else
> Exit For
> End if
> Next
> ---------------------
>
>
>
> Whole Source Code
>
> Sub PrintRecordsetNav( iNumPerPage, adodbConnection, adodbCommand,
> sTable, sURL, sQuerystring )
>
> Dim iTtlNumItems, iDBLoc, sSqlTemp, iTtlTemp
> Dim iDBLocTemp, sURLBeg, iA, iB, x, iTemp, rsObj
>
> iDBLoc = CInt(Request("iDBLoc"))
> iTtlNumItems = CInt(Request("iTtlNumItems"))
> ' Get ttl num of items from the database if it's Not already In
> the QueryString
> if (iTtlNumItems = 0) Then
> Set rsObj = Server.CreateObject("ADODB.Recordset")
> sSqlTemp = "SELECT COUNT(*) FROM " & sTable
> adodbCommand.CommandText = sSqlTemp
> rsObj.Open adodbCommand
> if Not(rsObj.EOF) Then
> iTtlNumItems = rsObj(0)
> End if
> rsObj.Close
> Set rsObj = Nothing
> End if
> iTtlTemp = iTtlNumItems \ iNumPerPage ' this is the number of
> numbers overall (use the "\" To return int)
> iDBLocTemp = iDBLoc \ iNumPerPage ' this is which number we are
> currently On (use the "\" To return int)
> if (sQuerystring <> "") Then
> sURLBeg = "<A href = """ & sURL & "?" & sQuerystring &
> "&iTtlNumItems=" & iTtlNumItems & "&iDBLoc="
> Else
> sURLBeg = "<A href = """ & sURL & "?iTtlNumItems=" &
> iTtlNumItems & "&iDBLoc="
> End if
>
> '***** BEGIN DISPLAY *****
> ' Print the "Previous"
> if (iDBLoc <> 0) Then
> Response.Write sURLBeg & (iDBLoc - iNumPerPage) &
> """>Previous</A> "
> End if
> ' Print the <<
> if (iDBLocTemp >= iNumPerPage) Then
> Response.Write sURLBeg & (( iDBLocTemp \ iNumPerPage ) *
> iNumPerPage ^ 2) - (iNumPerPage * 9) & """><<</A> "
> End if
>
> ' Print the numbers in between. Print them out in sets of 10.
> iA = ( iDBLocTemp \ iNumPerPage ) * iNumPerPage
> iB = ( iDBLocTemp \ iNumPerPage ) * iNumPerPage + iNumPerPage
> For x = iA To iB
> iTemp = (x * iNumPerPage)
> if (iTemp < iTtlNumItems) Then ' takes care of extra numbers
> after the overall final number
> if (iDBLoc = iTemp) Then
> Response.Write " <B>[" & x+1 & "]</B>"
> Else
> Response.Write " " & sURLBeg & (x * iNumPerPage) & """>" & x+1
> & "</A>"
> End if
> Else
> Exit For
> End if
> Next
>
> ' Print the >>
> if (iTtlTemp > iDBLocTemp) Then
> if ((iDBLocTemp + iNumPerPage) <= iTtlTemp) Then
> Response.Write " " & sURLBeg & (( iDBLocTemp \ iNumPerPage ) *
> iNumPerPage + iNumPerPage ) * iNumPerPage & """>>></A> "
> End if
> End if
> ' Print the "Next"
> if ((iDBLoc + iNumPerPage) < iTtlNumItems) Then
> Response.Write " " & sURLBeg & (iDBLoc + iNumPerPage) &
> """>Next</A>"
> End if
> '***** End DISPLAY *****
>
> End Sub
> '***************************************
> ' ****************************************




Aaron Bertrand [SQL Server MVP] 07-29-2005 12:49 PM

Re: asp Pagination Help
 
> I don't know how to reuse the following source code,

Maybe this will help:
http://www.aspfaq.com/2120




All times are GMT. The time now is 11:20 PM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.