Sort by column name in Listview

Posted on 2011-05-08
Last Modified: 2012-08-14
How can I implement sorting in a listview control in which the user can choose a column name from a dropdown of column names and asc/desc from a drop down too.

Question by:TrialUser
    LVL 29

    Accepted Solution

    Please check the link below, hope it may help:

    If this does not help - tell what control you are using. Why do you want to sort using dropdowns?

    LVL 83

    Expert Comment

    Again more details required.

    Author Comment

    I am displaying the product results in asp:listview. I would be sorting on stuff like :

    Price from Low to High
    Price from High to Low
    Best Selling

    and so on
    LVL 83

    Assisted Solution

    Try this code


    If DDLSort.Text = "Price from Low to High" Then
       dSet.Tables(0).DefaultView.Sort = "Price"
    ElseIf DDSort.Text = "Price from High to Low" Then
       dSet.Tables(0).DefaultView.Sort = "Price Desc"
    End If
    ListView1.DataSource = dSet.DefaultView

    Featured Post

    Maximize Your Threat Intelligence Reporting

    Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

    Join & Write a Comment

    IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
    Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
    how to add IIS SMTP to handle application/Scanner relays into office 365.
    In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor ( If you're interested in additional methods for monitoring bandwidt…

    734 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    19 Experts available now in Live!

    Get 1:1 Help Now