473,513 Members | 2,524 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Sorting column headings

I'm using the code below to display the results in rows with the column
header as hyperlinks that will sort the rows by colum heading. Is there a
way to have the results sorted (as default) in reverse order so that the
most recent are at the top of the page also when the user selects the Open
Date or Status column headings, sort the data in reverse order .
Code is below.
Thanks

<%
ppl_ctr=0
dim mthd
' Set up SELECT Statement (Order by if user selected)
If IsEmpty(Request.QueryString("Order")) Then
SQLStatement = "Select * From calls Order by callID"
strORDER = "Ordered by ID"
Else
SQLStatement = "SELECT * FROM calls ORDER BY " &
Request.QueryString("Order") & ", callID"
If (Request.QueryString("Order") = "callID") Then
strORDER = "Ordered by ID"
Else
strORDER = "Ordered by " & Request.QueryString("Order")
End If
End If
%>
<div align="center">
<center>
<table border="0" cellpadding="0" cellspacing="0" width="100%"
style="border-collapse: collapse" bordercolor="#111111">
<tr>
<td align="center" width="100%">
<font size="5">Support Calls</font>
</td>
</tr>
<tr>
<td align="center" width="100%">
<a href="default.asp">Return to Support Call Home Page</a></td>
</tr>
</tr>
<tr>
<td align="center" width="100%">
&nbsp;</td>
</tr>
</table>
</center>
</div>

<% Set RScalls = dbConnection.Execute(SQLStatement) %>

<table align="center" border="1" cellspacing="0" cellpadding="5">
<tr bgcolor="#B1C1D1">
<td rowspan="2"><font size="-1"><b><a
href="call_list.asp?Order=callID">ID</a></b><br></font></td>
<td width="50%" rowspan="2"><font size="-1"><b><a
href="call_list.asp?Order=Title">Title</a></b></font></td>
<td rowspan="2"><font size="-1"><b><a
href="call_list.asp?Order=OpenDate">Open Date</a></b></font></td>
<td rowspan="2"><font size="-1"><b><a
href="call_list.asp?Order=RecvBy">Logged By</a></b></font></td>
<td rowspan="2"><font size="-1"><b><a
href="call_list.asp?Order=status">Status</a></b></font></td>
<td rowspan="2"><font size="-1"><b><a
href="call_list.asp?Order=state">State</a></b></font></td>
<td colspan="3">
<p align="center"><font size="-1"><b>Severity</a></b></font></td>
</tr>
<tr bgcolor="#B1C1D1">
<td><font size="-1"><b><a href="call_list.asp?Order=Severity1 DESC">Sev
1</a></b></font></td>
<td><font size="-1"><b><a href="call_list.asp?Order=Severity2 DESC">Sev
2</a></b></font></td>
<td><font size="-1"><b><a href="call_list.asp?Order=Severity3 DESC">Sev
3</a></b></font></td>
</tr>
<% Do While Not RScalls.EOF
callscounter=callscounter+1 %>
<tr>
<td>
<small>
<% If (Request.QueryString("Order") <> "") Then %>

<form method="Get" action="call_call_list.asp" id=form24 name=form24>
<input type="hidden" name="Order"
value="<%=Request.QueryString("Order") %>">
<% End If %>

<a href="update.asp?submit=Update&callID=<%=RScalls(" callID")%>">
<%=RScalls("callID")%>
</a>
</td>
<td width="45%"><small><%=RScalls("title") %></small>&nbsp;</td>
<td><small><%=RScalls("OpenDate")%></small>&nbsp;</td>
<td><small><%=RScalls("RecvBy")%></small>&nbsp;</td>
<td><small><%=RScalls("status")%></small>&nbsp;</td>
<td><small><%=RScalls("state")%></small>&nbsp;</td>
<td><small><%=RScalls("severity1")%></small>&nbsp;</td>
<td><small><%=RScalls("severity2")%></small>&nbsp;</td>
<td><small><%=RScalls("severity3")%></small>&nbsp;</td>
</tr>
<% RScalls.movenext
Loop
%>
<% If callscounter=0 Then %>
<%= "No Calls were found at this time." %>
<% End If %>
</table>
Jul 19 '05 #1
2 1917
Carmen --

You can hard-code " DESC " to your SQLStatement, or make it variable like
your Querystring("Order"):

SQLStatement = "Select * From calls Order by callID DESC"
SQLStatement = "SELECT * FROM calls ORDER BY " &
Request.QueryString("Order") & ", callID DESC"

You can also sort different columns ASC (ascending) or DESC (descending),
for instance:

SELECT callID, customerName FROM calls ORDER BY callID DESC, customerName
ASC

would give you the calls in newer to older order, but then sort them by the
customer name column.

Do be careful, however, when using ORDER BY and make sure you avoid using
column collections that don't have a corresponding or covering index if the
dataset being sorted is large, or you're likely to impair performance (and
possibly elicit the wrath of your DBA).

Alan

=====

"carmen" <carmen@iyahoo_Spam.com> wrote in message
news:ua**************@tk2msftngp13.phx.gbl...
I'm using the code below to display the results in rows with the column
header as hyperlinks that will sort the rows by colum heading. Is there a
way to have the results sorted (as default) in reverse order so that the
most recent are at the top of the page also when the user selects the Open
Date or Status column headings, sort the data in reverse order .
Code is below.
Thanks

<%
ppl_ctr=0
dim mthd
' Set up SELECT Statement (Order by if user selected)
If IsEmpty(Request.QueryString("Order")) Then
SQLStatement = "Select * From calls Order by callID"
strORDER = "Ordered by ID"
Else
SQLStatement = "SELECT * FROM calls ORDER BY " &
Request.QueryString("Order") & ", callID"
If (Request.QueryString("Order") = "callID") Then
strORDER = "Ordered by ID"
Else
strORDER = "Ordered by " & Request.QueryString("Order")
End If
End If
%>

[snip]
Jul 19 '05 #2
Get data once.
Place in XML Data Island on Client and sort with JavaScript.
Why hit database and reload the data each time?

dlbjr
Pleading sagacious indoctrination!
Jul 19 '05 #3

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

Similar topics

4
21324
by: Thomas Jerkins | last post by:
When I write a create table SQL statement I want to add some information about the column heading of each column. How does the exact syntax for the create table look like (which includes this column data look)? How do I add later column headings ? Tom
4
1791
by: Rich Hurley | last post by:
We've just installed SQL Server 2000 on one of our servers and have noticed a strange behavior. When clicking the column headings in the job display in Enterprise Manager, the list is sorted (first click ascending, then descending) on the column clicked except for "Next Run Date." When we click on "Next Run Date," the list is reordered, but...
1
1627
by: Ross | last post by:
The following codes originally provided by a kind responder Toby A Inkster in another newsgroup for working on displaying a table on web capable of sorting are modified by me (a newbie). How to disable sorting by say, length and chart (last few codes at the end)? I find the order is important to display so cannot just single them out. <?php...
8
5211
by: Mike | last post by:
Hello, I have a few rather urgent questions that I hope someone can help with (I need to figure this out prior to a meeting tomorrow.) First, a bit of background: The company I work for is developing a web-based application, one part of which involves allowing the user the ability to page through transaction "history" information. The...
3
4148
by: Paula | last post by:
I need to do a summary using a crosstab query. The data has a Date field (Not named "Date"). I can do the Row Heading and Value but am having trouble with the Column Heading. The summary Columns needs to read like: Sept01 to Aug02 Sept02 to Aug03 Sept03 to Aug04 Can anyone give me a recommendation on how to get from the Date...
3
4842
by: PeterZ | last post by:
Hi, In a running C# app with a datagrid control I select all rows in the dataGrid using CTRL-A, I then paste into some other app like notepad or Word but the column headings get left off. Is there any way of including column headings when copying/pasting from a running datagrid to notepad? At this stage it looks like I have to write my...
19
25428
by: Owen T. Soroke | last post by:
Using VB.NET I have a ListView with several columns. Two columns contain integer values, while the remaining contain string values. I am confused as to how I would provide functionality to sort columns based on the column header the user has clicked in both Ascending and Descending formats.
6
2395
by: carlos123 | last post by:
I have a programming assignement that i have been working on for quite some time now. I need your guys' help. My assignement is to great a table with data in it. and it will have a combobox and 2 buttons to how it will be sorted( run the program and you'll see how its setup).The table will have a comboBox that includes the 4 headings. We have to...
5
4904
by: jrod11 | last post by:
hi, I found a jquery html table sorting code i have implemented. I am trying to figure out how to edit how many colums there are, but every time i remove code that I think controls how many colums there are, it crashes. There are currently 6 columns, and I only want 4. How do I remove the last two (discount and date)? Here is a link:...
0
7178
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7565
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7128
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
4759
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3255
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3242
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1612
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 we have to send another system
1
817
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
473
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.