473,395 Members | 2,436 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

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
'***************************************
' ****************************************
Jul 27 '05 #1
3 4308
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" <ke*******@gmail.com> wrote in message
news:db*************************@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
'***************************************
' ****************************************

Jul 27 '05 #2

Kelvin wrote:
*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
'***************************************
' **************************************** *


holy shit! that's MY code!

--
garraeth
------------------------------------------------------------------------
Posted via http://www.codecomments.com
------------------------------------------------------------------------

Jul 29 '05 #3
> I don't know how to reuse the following source code,

Maybe this will help:
http://www.aspfaq.com/2120
Jul 29 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Faree | last post by:
I am workign on a news portal which needs paginaiton as usual.but all the code i got depends on the number of records that will come from database :( .it is working well too. But i need...
11
by: ste | last post by:
Hi there, Further to my recent posts where I've received excellent help from Rik and Jerry, I've ended up with an image gallery on my website that displays images in a table, 3 images per row. ...
1
by: dhanu | last post by:
How to manage pagination in AJAX? My requirement is similar to GMails inbox feature. Whenever a new mail comes in,the newly arrived mail is at the start of my inbox and last row in that page...
1
by: OceanBreeze | last post by:
I am new to .Net. I am using ASP 2.0 and C#. I want to pupolate a data grid programatically using the values obtained from a list conating domain objects. E.g., DAL.GetEmployee() returns a...
0
by: OceanBreeze | last post by:
I am using C# Page_Laod function to populate a web page with a table populated with several records. The table, rows (containing values) are popuated programatically with the values obtained from...
1
by: shalini jain | last post by:
Hi, I want to know how can we do pagination using XSL. There are number of tutorials available on pagination using PHP but nothing with XSL. i am really stuck with my code. Below is the code that...
16
by: gnawz | last post by:
I have a pagination function I am using in a file called functions.php as below<? //Pagination functions function getPagingQuery($sql, $itemPerPage = 10) { if (isset($_GET) && (int)$_GET > 0) ...
4
by: ArizonaJohn | last post by:
Hello, The code below works great. The user enters a name into an HTML form, the code looks up a table with that name, and then that table is displayed. I am trying to use pagination with it,...
2
by: kkshansid | last post by:
this is my search page on which i am getting two parameters from previous page but the problem is that as soon as i click any other next pages my sql query fails as it doesnt get these two parameters...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.