473,503 Members | 2,165 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Paging, Subsort...

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"-->

Aug 2 '05 #1
1 1333
"Kevin" <ke***@DearingerAM.com> wrote in message
news:Ou**************@TK2MSFTNGP15.phx.gbl...
<snip>
Please do not multipost Kevin. This is definitely a database-related
question
so .asp.db was the perfect group in which to post it. Posting it here as
well did not increase your chances of getting an answer (most of us
subscribe to both groups). On the contrary, if somebody had taken his time
to answer it here, only to find that it was already resolved in the other
group, that person may have been annoyed enough to ignore any future posts
from you, thereby decreasing your chances of getting help in the future.

There are times when you will not be sure which group is most appropriate,
and you will want to post a question to both groups. In that situation, you
should use the cross-posting technique, rather than posting the same message
multiple times. To crosspost, put a semicolon-delimited* list of the
newsgroups to which you wish to post in the To: header of your post and post
it once. It, and any replies to it, will appear in all the newsgroups in
your list. So, if I reply in .asp.db, my reply will also appear here in
..asp.general.

* ... or whatever delimiter is recognized by your news client
--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From header is
my spam trap, so I don't check it very often. You will get a quicker
response by posting to the newsgroup.
Aug 2 '05 #2

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

Similar topics

0
2706
by: ck388 | last post by:
For some reason when I enable the callback feature of the gridview I still get a page refresh, that is it seems like there is a postback that occurs, not a callback which is just supposed to update...
6
1801
by: Shawn | last post by:
Hi. I already have a datagrid where I'm using paging. I have a stored procedure that fills a temp table with 200-500 rows and then sends back 10 records at the time. When I go to page 2 the SP...
2
2211
by: asad | last post by:
Hello friends, i am designing a ASP.NET page where i want to use custom paging bcoz data is too heavy so pls tell me how can i use custom paging in ASP.NET Thanks
0
954
by: Kevin | last post by:
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,...
2
6433
by: farhad13841384 | last post by:
Hi , I Hope You fine. I have some problem with this code for paging in asp.net this bottom code work correctly without any error but when I try to place separate code in .VB file then error is...
0
3373
by: anonieko | last post by:
This approach I found very efficient and FAST when compared to the rowcount, or Subquery Approaches. This is before the advent of a ranking function from DB such as ROW_NUMBER() in SQL Server...
2
1914
by: rn5a | last post by:
In a shopping cart app, a ASPX page retrieves the order details & personal details of a user from a MS-Access database table depending upon the username of the user. The order details of a...
3
3731
by: Ronald S. Cook | last post by:
I was told that if calling lots of records from the database (let's say 100,000), that the GridView's paging feature would automatically "handle" everything. But the 100,000 records are still...
5
3197
by: Donald Adams | last post by:
Hi, I will have both web and win clients and would like to page my data. I could not find out how the datagrid control does it's paging though I did find some sample code that says they do it...
0
7205
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7287
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7353
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...
1
7011
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...
1
5023
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4689
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3180
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1521
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
401
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.