954,600 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

ASP paging

HI ..
any one of you people can help me in asp paging..
Its actually a knowledge base link in which i am displaying the records
based on the filtering we want.it dispalys the records but where to include the paging code...
i got some code from net..
but its not displaying properly....
:confused:

paru
Newbie Poster
3 posts since Jul 2005
Reputation Points: 10
Solved Threads: 0
 

inside the loop after the stuff to be shown ie

<% do while recordset <> bof and recordset <> eof

your recordset fields

recordset.movenext (cant remember exact code)#

loop %>

william_stam
Junior Poster
131 posts since Mar 2005
Reputation Points: 10
Solved Threads: 2
 

No..
See for recordset there are some properties like how many records to be displayed in a single page if we click next it has to show the second page.(that means second set of records)....
:idea:

paru
Newbie Poster
3 posts since Jul 2005
Reputation Points: 10
Solved Threads: 0
 

This' from an old guest book i wrote.
Not the most stream lined code ever, but should give you an idea....

<%
Dim adoCon 			
Dim rsGuestbook
Dim strSQL
Dim adoCon1
Dim strEmail
Dim strSQL1
Dim rsEmail
Dim testv
Dim test1
Dim intRecordspp
Dim intTotalRecords
Dim intTotalPages
Dim intPageNum
Dim strBlah1
Dim strBlah2

If Request.QueryString("rpp") = "" Then
	intRecordspp = 10
Else
	intRecordspp = CInt(Request.QueryString("rpp"))
End If

If Request.QueryString("PageNumber") = "" Then
	intPageNum = 1
Else
	intPageNum = CInt(Request.QueryString("PageNumber"))
End If	

Set adoCon = Server.CreateObject("ADODB.Connection")
adoCon.Open "Driver={mySQL};......
Set rsGuestbook = Server.CreateObject("ADODB.Recordset")
strSQL = "SELECT Name, Comments, Date_stamp FROM users ORDER BY Date_stamp DESC;"
rsGuestbook.CursorType = 3
rsGuestbook.Open strSQL, adoCon
rsGuestbook.PageSize = intRecordspp

If NOT rsGuestbook.EOF Then rsGuestbook.AbsolutePage = intPageNum
intTotalRecords = rsGuestbook.RecordCount
intTotalPages = rsGuestbook.PageCount
%>
<A NAME="top">
<TABLE CELLPADDING=10 CELLSPACING=0 BORDER=0 WIDTH="100%">
	<TR>
		<TD>Guestbook currently holds <B><%=intTotalRecords%></B> comments.<BR><A HREF="addcom.asp">Add comment</A>
<TABLE CELLPADDING=0 CELLSPACING=0 BORDER=0 WIDTH="100%">
<TR><TD></TD><TD align="right">Page <%= intPageNum%> of <%= intTotalPages%>
<BR>
<%
If intPageNum = 1 Then
Else %>
<A HREF="gb.asp?PageNumber=<%= intPageNum -1%>&rpp=<%= Request.QueryString("rpp")%>">Back</A>
<%
End If
%>

<% If intPageNum < intTotalPages Then %>
<A HREF="gb.asp?PageNumber=<%= intPageNum +1%>&rpp=<%= Request.QueryString("rpp")%>">Next</A>
<%
Else
End If
%>
</TD></TR></TABLE><p>
<% 
for strBlah2 = 1 to intRecordspp
if Not rsGuestbook.EOF Then

%>

<TABLE WIDTH="100%" CELLPADDING=1 CELLSPACING=0 BORDER=0>
  <TR>
    <TD CLASS="field">
      <TABLE WIDTH="100%" CELLPADDING=2 CELLSPACING=0 BORDER=0>
        <TR>
          <TD CLASS="border">Comment posted by <B><%= rsGuestbook("Name") %></B></TD>

        </TR>
        <TR>
          <TD><BR><%= rsGuestbook("Comments") %><P></TD>
        </TR>
	<TR>
	  <TD align=right><%= rsGuestbook("Date_stamp") %></TD>
	</TR>
      </TABLE>
    </TD>
  </TR>
</TABLE>

<BR>
<%
	rsGuestbook.MoveNext
End If
Next

'Reset server objects
rsGuestbook.Close
Set rsGuestbook = Nothing
Set adoCon = Nothing
Set adoCon1 = Nothing 
Set rsEmail = Nothing
%>
<P align=right><A HREF="#top">Top</A><BR>&nbsp<BR>
Page <%= intPageNum%> of <%= intTotalPages%>
<BR>
<%
If intPageNum = 1 Then
Else %>
<A HREF="gb.asp?PageNumber=<%= intPageNum -1%>&rpp=<%= Request.QueryString("rpp")%>">Back</A>
<%
End If
%>

<% If intPageNum < intTotalPages Then %>
<A HREF="gb.asp?PageNumber=<%= intPageNum +1%>&rpp=<%= Request.QueryString("rpp")%>">Next</A>
<%
Else
End If
%>
madmital
Junior Poster
120 posts since Jun 2005
Reputation Points: 10
Solved Threads: 5
 
cancer10
Posting Whiz in Training
234 posts since Dec 2004
Reputation Points: 58
Solved Threads: 1
 

you must declarate

erpasoleh
Newbie Poster
2 posts since Feb 2007
Reputation Points: 10
Solved Threads: 0
 

There is a short but useful article here.. You should look at this:

Listing Records and ADO Recordset Paging in ASP

webmstr
Newbie Poster
2 posts since Nov 2009
Reputation Points: 10
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You