Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 360675
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T12:30:41+00:00 2026-05-12T12:30:41+00:00

I have a datalist that receives values from a MySQL database. This datalist can

  • 0

I have a datalist that receives values from a MySQL database. This datalist can be sorted by various column values such ‘Title’, ‘Author’, ‘Published Date’, etc. To determine what value to sort by, the value is inserted into the query string.

I.e. http://www.web.com/default.aspx?order_by=title

I also determine wheter to order in ascending order or descending order.

I.e. http://www.web.com/default.aspx?order_by=title&direction=asc

I want to be able to set the direction to asc if the

(a working example of what I’m looking to do can be found at

http://www.milwaukeejobs.com/jobs/category/Information-Technology-Internet-Web-Development/Milwaukee,-WI/1306

*Notice if you click the sort values such as by Date its set to ASC, if you click it again its set to DSC; I’d like to do this on my site * )

I’m not sure how to do this. I was thinking of a If Page.IsPostback condition, but clicking the url does not cause a postback. I thought about grabbing the sender object, or system.eventargs variables that are sent through the Page.Onload event, but I’m not sure if I could do anything with these. Any ideas?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T12:30:42+00:00Added an answer on May 12, 2026 at 12:30 pm

    I would maintain the sort order of the columns within the page itself as hidden input fields (with runat=”server” specified). When a link is clicked, you can flip the direction of this field prior to postback. This gets around having to check for IsPostBack status.

    Something like this:

    <input type="hidden" id="TitleSortOrder" Runat="server" />
    <asp:LinkButton id="TitleHeader" onclick="return(FlipSortOrder('Title'));" />
    
    function FlipSortOrder(type)
    {
      var sortOrder = document.getElementById(type + "SortOrder");
      sortOrder.value = sortOrder.value === "ASC" ? "DESC" : "ASC";
      return true;
    }
    

    In server-side code, you can refer to the value of the title sort direction using the TitleSortOrder.Value property.

    To make this work in MySQL, you’ll need to execute a dynamic query if you intend for the sorting to happen at the database level. This is similar to post Dynamic Column name in MYSQL, but in the interests of keeping this all together, the pattern of executing dynamic SQL in MySQL looks like this:

    SET @qry = 'your query here';
    PREPARE stmt FROM @qry;
    EXECUTE stmt;
    DEALLOCATE PREPARE stmt;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 276k
  • Answers 276k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer I'm getting some leaks (obvserved by Instruments) when trying to… May 13, 2026 at 2:53 pm
  • Editorial Team
    Editorial Team added an answer Use this form: =(B0+4)/$A$0 The $ tells excel not to… May 13, 2026 at 2:53 pm
  • Editorial Team
    Editorial Team added an answer I would not rebase at all on a branch which… May 13, 2026 at 2:53 pm

Related Questions

I have a program that listens on a port waiting for a small amount
I'm working through Real World Haskell , and at the moment doing the exercises
I have a DataList that is bound to a SQlDataSource. The SQLDataSource returns a
Kinda hard to explain, but i'll try. I have a datalist that is populated

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.