Results 1 to 3 of 3
  1. #1
    Join Date
    Jan 2005

    Unanswered: inserting hyperlinks to sort data

    I have an asp page which displays the results of a query. is there a way to insert hyperlinks above the data so when clicked, it will sort the data ascending/descending...something like that. here's an example. i have my table. at the top of the table i have the column names. i want to hyperlink the column names so when clicked, it will sort the data based on that column. thanks for any help.

  2. #2
    Join Date
    Nov 2003
    Christchurch, New Zealand
    If you want to sort you need to re-run the query that collected the data and add and orber by clause.... eg
    select * from cases order by caseNumber
    (of course don't use * specify your fields)

    So you make the order by part of your sql statement dynamic and pass the field you want to order by in the querystring... something like...
    <a href="caseResults.asp?orderby=caseNumber">Case Number</a>
    strSql = "select * from cases"
    orderBy = Request.QueryString("orderby")
    if orderBy<>"" then strSql = strSql + "order by " orderBy
    if you have a where clause included in the query you will need to make sure you have access to the data for this where clause as well.

  3. #3
    Join Date
    Jun 2003
    And here's a related resource:

    Database Sort
    J. Paul Schmidt, Freelance Web and Database Developer
    Access Database Sample, Web Database Sample, ASP Design Tips

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts