473,396 Members | 1,966 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,396 software developers and data experts.

Paging, subsorting issue...

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")%>'><%=rsIt ems("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("Equi pmentType")%></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"-->

Nov 19 '05 #1
0 953

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

Similar topics

2
by: Mark | last post by:
I am attempting to build a repeating list using a repeater control. I want to add a checkbox to each item (line) and 'Select All' and 'Clear All' buttons. I have figured out how to do this...
2
by: RJN | last post by:
Hi Sorry for posting again. I have a datagrid which is put inside a div tag to make it scrollable. I need to page the datagrid. The page numbers appear at the bottom of the datagrid and has...
4
by: Ken Varn | last post by:
I am displaying data from a SQL Server database on my ASP.NET web form. The data table that I am displaying is huge and it must be paged. What I would like to do is display 10 records at a time...
4
by: news.microsoft.com | last post by:
I've looked in the help and at each of the properties for the grid view, but can't seem to find what I need. I have allowpaging set to true for my gridview and when the page loads I go and fetch...
5
by: LDD | last post by:
Hi Folks I'm trying to determine a way to handle paging, filtering and sorting in a datagrid. If I choose to filter and sort, I'd like to return a subset. If that resultset has more records...
0
by: pmohando | last post by:
DB2 version 7 running on Aix 5.3 platform, we face the problem on paging space keeping on increasing and reaches upto 99% and only solution is server made to restart for every 20 days. DB2 is not...
1
by: John Mott | last post by:
Hi All, I recently read a post that said that google and other spiders are unable to navigate paging in the GridView control because it uses postbacks and it can't determine the url. I've...
8
tharden3
by: tharden3 | last post by:
Hey all, I need some help with PHP code for paging my products on my site. I posted questions asking for help in the past, and was directed to this tutorial for help. The code that the tutorial gives...
1
by: chris3vic | last post by:
I have a dynamically created datagrid, populated from a dataset that is filled by a sql string triggered by a command button. The application itself allows a user to input a selection of criteria and...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.