SitePoint Sponsor

User Tag List

Results 1 to 3 of 3

Thread: Sort recordset

  1. #1
    SitePoint Enthusiast
    Join Date
    Nov 2009
    Posts
    73
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Sort recordset

    Hi

    I have a recordset that i would like the enduser using the program can order the results displayed on screen themselves i.e. in excel you can order the data by asc or desc by clicking on the relevant column.

    I know in my query that is fetching the data, i can use the order by clause but i would like the user to be able to do it themselves. I have 4 columns of data that would need this applying to.

    I am aware i can use a requestQuerystring method but is there another/better way of executing this?


    Thanks

  2. #2
    SitePoint Wizard siteguru's Avatar
    Join Date
    Oct 2002
    Location
    Scotland
    Posts
    3,631
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    If the data is displayed in tabular form, simply make the column header a link the user can click on.

    Code:
    <a href="page.asp?sort=column1">Column 1</a>
    When they click the link you read the querystring and sort (ORDER BY) the recordset on that column. You could also incorporate a mechanism to toggle the sort order (ASC | DESC) if they click that heading again. (e.g. default to sort one way, then sort the opposite way if clicked again).
    Ian Anderson
    www.siteguru.co.uk

  3. #3
    ♪♪ ♪ ♪ ♪ ♪♪ ♪ ♪♪ Markdidj's Avatar
    Join Date
    Sep 2002
    Location
    Bournemouth, South UK
    Posts
    1,551
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    A hint......
    Although you can't find special characters when used in a submit button, you can find the string position of the word used for the submit's value
    LiveScript: Putting the "Live" Back into JavaScript
    if live output_as_javascript else output_as_html end if


Bookmarks

Posting Permissions

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