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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

splitting records

Status
Not open for further replies.

DKL01

Programmer
Sep 14, 2000
233
US
Hello All :

My asp screen looks something like hotmail listing all your mails.

If the database returns more than 50 records I should provide the option NEXT 50 Matches option. Means the screen should display only 50 records at a time. This is similar to what you get when you do a search on yahoo or altavista.

I really appreciate if somebody tells me how to implement this.

Thanks [sig][/sig]
 
Dilip
You need to use pageing of your recordset, inorder to divide the results up into uniform blocks that you can then scrolled through.


try this:
add these routines:

dim nPage
public sub PagingSetup(oRS)
if request(&quot;Page&quot;) <> &quot;&quot; then
nPage = request(&quot;Page&quot;)
else
nPage = 1
end if
if IsEmpty(nPage) Or nPage = &quot;&quot; or nPage < 1 then
nPage=1
end if
If oRS.RecordCount > 0 Then
oRS.AbsolutePage = nPage
End If
end sub


public sub ZoomToPage(oRS,sPageName,nPage)
on error resume next
%>
<% if nPage-1 > 0 then %>
<a href=&quot;<%=sPageName%>?Page=<%=nPage-1%>&quot;><<</a>
<%end if%>
<% if nPage-10 > 0 then %>
<a href=&quot;<%=sPageName%>?Page=<%=nPage-10%>&quot;><%=nPage-10%>
</a><%end if%>
<% if nPage-9 > 0 then %>
<a href=&quot;<%=sPageName%>?Page=<%=nPage-9%>&quot;><%=nPage-9%>
</a><%end if%>
<% if nPage-8 > 0 then %>
<a href=&quot;<%=sPageName%>?Page=<%=nPage-8%>&quot;><%=nPage-8%>
</a><%end if%>
<% if nPage-7 > 0 then %>
<a href=&quot;<%=sPageName%>?Page=<%=nPage-7%>&quot;><%=nPage-7%>
</a><%end if%>
<% if nPage-6 > 0 then %>
<a href=&quot;<%=sPageName%>?Page=<%=nPage-6%>&quot;><%=nPage-6%>
</a><%end if%>
<% if nPage-5 > 0 then %>
<a href=&quot;<%=sPageName%>?Page=<%=nPage-5%>&quot;><%=nPage-5%>
</a><%end if%>
<% if nPage-4 > 0 then %>
<a href=&quot;<%=sPageName%>?Page=<%=nPage-4%>&quot;><%=nPage-4%>
</a><%end if%>
<% if nPage-3 > 0 then %>
<a href=&quot;<%=sPageName%>?Page=<%=nPage-3%>&quot;><%=nPage-3%>
</a><%end if%>
<% if nPage-2 > 0 then %>
<a href=&quot;<%=sPageName%>?Page=<%=nPage-2%>&quot;><%=nPage-2%>
</a><%end if%>
<% if nPage-1 > 0 then %>
<a href=&quot;<%=sPageName%>?Page=<%=nPage-1%>&quot;><%=nPage-1%>
</a><%end if%>
<%if nPage > 0 then %>
<%=nPage%>
<%end if%>
<%if nPage+1 <= oRS.PageCount then %>
<a href=&quot;<%=sPageName%>?Page=<%=nPage+1%>&quot;><%=nPage+1%></a>
<%end if%>
<% if nPage+2 <= oRS.PageCount then %>
<a href=&quot;<%=sPageName%>?Page=<%=nPage+2%>&quot;><%=nPage+2%></a>
<%end if%>
<% if nPage+3 <= oRS.PageCount then %>
<a href=&quot;<%=sPageName%>?Page=<%=nPage+3%>&quot;><%=nPage+3%></a>
<%end if%>
<% if nPage+4 <= oRS.PageCount then %>
<a href=&quot;<%=sPageName%>?Page=<%=nPage+4%>&quot;><%=nPage+4%></a>
<%end if%>
<% if nPage+5 <= oRS.PageCount then %>
<a href=&quot;<%=sPageName%>?Page=<%=nPage+5%>&quot;><%=nPage+5%></a>
<%end if%>
<% if nPage+6 <= oRS.PageCount then %>
<a href=&quot;<%=sPageName%>?Page=<%=nPage+6%>&quot;><%=nPage+6%></a>
<%end if%>
<% if nPage+7 <= oRS.PageCount then %>
<a href=&quot;<%=sPageName%>?Page=<%=nPage+7%>&quot;><%=nPage+7%></a>
<%end if%>
<% if nPage+8 <= oRS.PageCount then %>
<a href=&quot;<%=sPageName%>?Page=<%=nPage+8%>&quot;><%=nPage+8%></a>
<%end if%>
<% if nPage+9 <= oRS.PageCount then %>
<a href=&quot;<%=sPageName%>?Page=<%=nPage+9%>&quot;><%=nPage+9%></a>
<%end if%>
<% if nPage+10 <= oRS.PageCount then %>
<a href=&quot;<%=sPageName%>?Page=<%=nPage+10%>&quot;><%=nPage+10%></a>
<%end if%>
<% if nPage+1 <= oRS.PageCount then %>
<a href=&quot;<%=sPageName%>?Page=<%=nPage+1%>&quot;>>></a>
<%end if%>
<%end Sub
'-----------------------------------------------------------------------
%>


then add this to rs:
rs.pagesize = i '(no. you want to display)

then add this in the page:
<%ZoomToPage rs,&quot;display.asp&quot;,nPage%> 'pass in rs, page name, page number

then you need to put a incremental no. in your rs loop and stop the rs loop when no. is equal to pagesize eg.

<%do until rs.EOF or iRec = rs.PageSize
iRec = iRec + 1
%>

This should sort it. [sig][/sig]
 
Thanks guys.
I have some problem with this logic.
Each record displayed will have check box ( like hotmail screen ). User can select the check box if they want to delete selected records. If we use recordset paging logic I'm wondering how to retain the previously selected records when we display next set of records.


[sig][/sig]
 
Guys,

It's urgent.
I really appreciate some help.

Thanks [sig][/sig]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top