Professional Web Applications Themes

Sort db results by clicking column header - ASP Database

I have a site that is hosted on a Win 2003 Server, IIS6, ASP.NET, MS Access, MS SQL Server. My site pulls dbase results and some users want to be able to sort the data by clicking the header of the result. For example: Column Names = Invoice Number, Client, Invoice Date How can I program it so that when they click on the column header "Invoice Number", it will sort the results by Invoice Number ascending? Then they click it again and it will sort the results descending? Thanks in advance, Lee...

  1. #1

    Default Sort db results by clicking column header

    I have a site that is hosted on a Win 2003 Server, IIS6, ASP.NET, MS Access,
    MS SQL Server.

    My site pulls dbase results and some users want to be able to sort the data
    by clicking the header of the result.

    For example:

    Column Names = Invoice Number, Client, Invoice Date

    How can I program it so that when they click on the column header
    "Invoice Number",
    it will sort the results by Invoice Number ascending? Then they click it
    again and it will sort the results descending?

    Thanks in advance,

    Lee


    Lee Guest

  2. #2

    Default Re: Sort db results by clicking column header

    Under the ColHeader you place a link to the same page.

    <a href="thisPage.asp?sortOrder=1">NAME</a>
    <a href="thisPage.asp?sortOrder=2">DATE</a>
    <a href="thisPage.asp?sortOrder=3">WHATEVER</a>

    Select the sortOrder value the create you ORDER BY


    John Guest

  3. #3

    Default Re: Sort db results by clicking column header

    "Lee" <org> wrote in message
    news:phx.gbl... 
    Access, 
    data 
    it 

    To enhance up John's response:

    Dim strSQL
    strSQL = "SELECT InvoiceNumber, Client, InvoiceDate"
    strSQL = strSQL & " FROM InvoiceTable"
    strSQL = strSQL & " ORDER BY " & RequestForm("ORD")
    strSQL = strSQL & " " & RequestForm("SEQ")

    <tr>
    <th>
    Invoice Number &nbsp;
    <a href="thisPage.asp?ORD=InvoiceNumber&SEQ="><img src='up.gif'></a>
    <a href="thisPage.asp?ORD=InvoiceNumber&SEQ=DESC"><im g
    src='down.gif'></a>
    </th>
    <th>
    Client &nbsp;
    <a href="thisPage.asp?ORD=Client&SEQ="><img src='up.gif'></a>
    <a href="thisPage.asp?ORD=Client&SEQ=DESC"><img src='down.gif'></a>
    </th>
    <th>
    Invoice Date &nbsp;
    <a href="thisPage.asp?ORD=InvoiceDate&SEQ="><img src='up.gif'></a>
    <a href="thisPage.asp?ORD=InvoiceDate&SEQ=DESC"><img src='down.gif'></a>
    </th>
    </tr>


    McKirahan Guest

Similar Threads

  1. control over a column in datagrid by clicking its header
    By sakons in forum ASP.NET Data Grid Control
    Replies: 2
    Last Post: December 13th, 01:55 PM
  2. Displaying current sort indication in the header of a column
    By Eric Caron in forum ASP.NET Data Grid Control
    Replies: 2
    Last Post: May 26th, 01:22 PM
  3. Image in header column (not replacing column header text)
    By hansiman in forum ASP.NET Data Grid Control
    Replies: 3
    Last Post: February 7th, 12:17 AM
  4. Any script to sort SQL results?
    By Lurk Master Flex in forum PHP Development
    Replies: 2
    Last Post: November 25th, 06:57 PM
  5. Replies: 1
    Last Post: September 9th, 07:16 AM

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
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139