Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP General > asp Pagination Help

Reply
Thread Tools

asp Pagination Help

 
 
Kelvin
Guest
Posts: n/a
 
      07-27-2005
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
'***************************************
' ****************************************
 
Reply With Quote
 
 
 
 
Steven Burn
Guest
Posts: n/a
 
      07-27-2005
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" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) 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
> '***************************************
> ' ****************************************



 
Reply With Quote
 
 
 
 
Aaron Bertrand [SQL Server MVP]
Guest
Posts: n/a
 
      07-29-2005
> I don't know how to reuse the following source code,

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


 
Reply With Quote
 
 
 
Reply

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 Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Pagination problem with asp.net 1.1 datagrid Julia B ASP .Net 2 10-02-2008 08:14 AM
ASP.Net 2.0 Repeater Pagination and SORT Chaprasi ASP .Net 1 02-02-2006 12:18 PM
Datagrid: having pagination and a button column Child ASP .Net 0 08-19-2003 05:06 PM
Re: datagrid custom pagination Sreejumon[MVP] ASP .Net 0 07-08-2003 05:09 AM
DataGrid Pagination Joseph D. DeJohn ASP .Net 3 07-04-2003 09:11 AM



Advertisments