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

  • SEARCH
  • Home
  • 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

Related Questions

I have a DataList control that displays a set of elements. Can anyone point
I have a table that is created in a DataList in ASP.Net. This table
I have a datalist that shows information from a SQL table perfectly. Is there
I have Datalist that is inside an updatepanel and it is in panel in
Kinda hard to explain, but i'll try. I have a datalist that is populated
I have a datalist inside a usercontrol that gets loaded into a page where
I have a datalist being generated with ASP, but unfortunately the jQuery script that
I have a DataList that Displays some Posts with a RadioButtonList inside where it
I have a datalist that contains a gridview inside its itemtemplate. on the item-data_bound
Hey guys I got a weird issue.. I have a datalist that's only loaded

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.