Paging, subsorting issue...

K

Kevin

Can anyone point me to a code example where a recordset.absolutepage is sorted independantly of the original recordset. That is; if I populate an ADO recordset with an ORDER BY ListingDate clause, and I need to (subsort) recordset.absolutepage five of my paging on another field, say for example AskingPrice, I'm stuck.

My goal is for my users to be able to page through my recordset, sort a page if desired, and continue through the recordset. The records on any page are sorted, and the same records are displayed, just in a new (subsort) oder.

I'm not using the data controls, just plain ASP...

Thanks

Kev

Current code below...


<!--#include file="Utilities.asp"-->
<link href="styles/main.css" rel="stylesheet" type="text/css">
<!--#include file="header.asp"-->
<!--#include file="Menu.asp"-->
<%
check_security(2)
%>
<%

If Session("UserID") = "" Then
Response.Redirect "Login.asp"
End if

Dim rsItems, strSort

strSort = request("sortby")

strSQL = "SELECT Item.ItemID, Users.CompanyName, EquipmentTypes.EquipName, Item.EquipmentType, Item.LoadSize, Item.PickupDate, Item.SPCountry, Item.SPState, " & _
"Item.SPCity, Item.DPCountry, Item.DPState, Item.DPCity, Item.Description, Item.AskingPrice, Item.SellerID, Item.ListingDate, Item.ExpirationDate, Item.ItemStatus " & _
"FROM (Item INNER JOIN EquipmentTypes ON Item.EquipmentType = EquipmentTypes.EquipCode) LEFT JOIN Users ON Item.SellerID = Users.UserID " & _
"WHERE Item.ExpirationDate > #" & FormatDateTime(Now,2) & "# " & _
"AND ItemStatus = 'Active' "

If request("LoadSize") <> "" then
strSQL = strSQL & "AND LoadSize = '" & request("LoadSize") & "' "
End if

If request("EquipmentType") <> "" then
strSQL = strSQL & "AND EquipmentType = '" & request("EquipmentType") & "' "
End if

If request("SPCountry") <> "" then
strSQL = strSQL & "AND SPCountry = '" & request("SPCountry") & "' "
End if

If request("SPState") <> "" then
strSQL = strSQL & "AND SPState = '" & request("SPState") & "' "
End if

If request("DPCountry") <> "" then
strSQL = strSQL & "AND DPCountry = '" & request("DPCountry") & "' "
End if

If request("DPState") <> "" then
strSQL = strSQL & "AND DPState = '" & request("DPState") & "' "
End if

strSQL = strSQL & "ORDER BY PickupDate;"

page_no = request("page_no")
if page_no = "" then page_no = 1

Set rsItems = Server.CreateObject("ADODB.Recordset")

if strSql <> "" then
rsItems.CursorLocation = 3
rsItems.CacheSize = 5
rsItems.Sort = "PickupDate, " & strSort
rsItems.Open strSql, objConn
if not rsItems.EOF then
rsItems.MoveFirst
rsItems.PageSize = 5
max_count = cInt(rsItems.PageCount)
num_recs = rsItems.RecordCount
rsItems.AbsolutePage = page_no
results = true
for each tmp in request.querystring
if tmp <> "page_no" AND tmp <> "sortby" then
request_string = request_string & tmp & "=" & request.querystring(tmp) & "&"
end if
next
else
results = false
rsItems.Close
end if
else
results = false
end if
rec_count = 0
%>
<table cellpadding="0" cellspacing="0">
<tr>
<td>&nbsp;</td>
</tr>
<tr>
<td><h1>Browse Loads</h1></td>
</tr>
<tr>
<td><li>Click Company Name to bid on the load.</li>
<li>Click the column headers to sort each Pickup Date by the column name.</li>
<li>Place your mouse over the Type code to see the full type description.</li>
<li>You cannot bid on your own loads.</li></td>
</tr>
<tr>
<td>&nbsp;</td>
</tr>
</table>
<%

if results = true then

%>
<table width="760px" cellpadding='0' cellspacing='0'>
<tr>
<td class='tdHeader'>Company</td>
<td class='tdHeader'><a href="<%=request.servervariables("script_name")%>?<% =request_string %>page_no=<% =page_no %>&sortby=LoadSize">Size</a></td>
<td class='tdHeader'><a href="<%=request.servervariables("script_name")%>?<% =request_string %>page_no=<% =page_no %>&sortby=EquipmentType">Type</a></td>
<td class='tdHeader'><a href="<%=request.servervariables("script_name")%>?<% =request_string %>page_no=<% =page_no %>&sortby=PickupDate">Pickup Date</a></td>
<td class='tdHeader'><a href="<%=request.servervariables("script_name")%>?<% =request_string %>page_no=<% =page_no %>&sortby=SPCity">Starting Point</a></td>
<td class='tdHeader'><a href="<%=request.servervariables("script_name")%>?<% =request_string %>page_no=<% =page_no %>&sortby=DPCity">Destination</a></td>
<td class='tdHeader'><a href="<%=request.servervariables("script_name")%>?<% =request_string %>page_no=<% =page_no %>&sortby=AskingPrice">Payment Amt</a></td>
</tr>
<%

do while not rsItems.EOF AND (rec_count < rsItems.Pagesize)

on error resume next

%>
<tr>
<% If Session("UserID") <> "" AND Session("UserID") <> rsItems("SellerID") Then %>
<td align="left" class='tdData'><a href='Bid.asp?Item=<%=rsItems("ItemID")%>'><%=rsItems("ItemReference")%></a></td>
<% Else %>
<td class='tdData' align='left'><%=rsItems("ItemReference")%></td>
<% End If %>
<td class='tdData' align='center'><%= rsItems("LoadSize") %></td>
<td class='tdData' align='center'><a title='<%=rsItems("EquipName")%>'><%=rsItems("EquipmentType")%></a></td>
<td align='center' class='tdData'><%= rsItems("PickupDate")%></td>
<td align='left' nowrap class='tdData'>&nbsp;<a href="http://www.mapquest.com/maps/map.adp?country=<%=rsItems("SPCountry")%>&state=<%=rsItems("SPState")%>&city=<%=rsItems("SPCity")%>&CID=lfmaplink" target="_blank"><font color="#FF0000" size="1">Map</font></a>&nbsp;<%= rsItems("SPCity") & ", " & rsItems("SPState")%></td>
<td align='left' nowrap class='tdData'>&nbsp;<a href="http://www.mapquest.com/maps/map.adp?country=<%=rsItems("DPCountry")%>&state=<%=rsItems("DPState")%>&city=<%=rsItems("DPCity")%>&CID=lfmaplink" target="_blank"><font color="#FF0000" size="1">Map</font></a>&nbsp;<%= rsItems("DPCity") & ", " & rsItems("DPState") %></td>
<td class='tdData' align='right'><%= formatcurrency(rsItems("AskingPrice")) %>&nbsp;</td>
</tr>
<%
rsItems.MoveNext
rec_count = rec_count + 1
loop
rsItems.Close
Set rsItems = Nothing
%>
</table>
<% else %>
<center>
<h2>No loads currently listed</h2>
</center>
<%

end if

if max_count > 1 then

%>
<table width="760px" cellpadding="0" cellspacing="0" class="NavTable">
<tr>
<td align=center width="20%" class=NavFont><% if page_no > 1 then %>
<a class=HeaderFont href="<% =request.servervariables("script_name") %>?<% =request_string %>page_no=1&sortby=<% =request("sortby")%>">First</a>
<% else %>
<% end if %>
</td>
<td align=center width="20%" class=NavFont><% if page_no > 1 then %>
<a class=HeaderFont href="<% =request.servervariables("script_name") %>?<% =request_string %>page_no=<% =page_no-1 %>&sortby=<%=request("sortby")%>">Previous</a>
<% else %>
<% end if %>
</td>
<td align=center width="20%" class=NavFont> Records:&nbsp;<%=num_recs%> </td>
<td align=center width="20%" class=NavFont><% if cInt(page_no) < cInt(max_count) then %>
<a class=HeaderFont href="<% =request.servervariables("script_name") %>?<% =request_string %>page_no=<% =page_no+1 %>&sortby=<% =request("sortby")%>">Next</a>
<% end if %>
</td>
<td align=center width="20%" class=NavFont><% if cInt(page_no) < cInt(max_count) then %>
<a class=HeaderFont href="<% =request.servervariables("script_name") %>?<% =request_string %>page_no=<% =cInt(max_count) %>&sortby=<% =request("sortby")%>">Last</a>
<% end if %>
</td>
</tr>
</table>
<% end if %>
<!--#include file="footer.asp"-->
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,764
Messages
2,569,567
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top