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 8085109
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T18:00:36+00:00 2026-06-05T18:00:36+00:00

I have a list view which is bound to a DataTable source. The sorting

  • 0

I have a list view which is bound to a DataTable source.
The sorting works, kinda.

For text is fine but not so much for numbers.

For example if I sort 1-12 descending I get 9,8,7,6,5,4,3,2,12,11,10,1.

How to get the proper sequence?

I am using:

lvPos.Sort("Position", SortDirection.Descending);
  • 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-06-05T18:00:37+00:00Added an answer on June 5, 2026 at 6:00 pm

    You’re likely going to have to do the sorting yourself instead of relying on ListView’s sort method.

    If you’re sorting just using code, this is very easy. Just shove your DataTable into a DataView and use the DataView’s Sort method. Then bind to your DataView instead of your DataTable.

    var view = new DataView(dtTable);
    view.Sort = "Position"; //or "Position DESC"
    lvPos.DataSource = view;
    lvPos.DataBind();  //use lvPos.DataBind(true) to raise the "OnDataBinding" event.
    

    If you’re sorting from the ListView’s sort methods (i.e. you have something in the page triggering the ListView.Sorting/Sorted events), then you would have to hook on to the Sorting event and cancel it. Follow up with the previous technique of shoving the DataTable into a DataView (or re-use the DataView!), sort by the new expression, and rebind your data.

    private void lvPos_Sorting(object sender, ListViewSortEventArgs args)
    {
       var view = new DataView(dtTable);
       view.Sort = args.SortExpression;
       lvPos.DataSource = view;
       lvPos.DataBind();
       args.Cancel = true;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a drop down list on a form view which are both bound
I have a List<Person> which is bound to a grid view. I want to
I have a View which has a list of items bound to my ViewModel
I have chat list view in which sender name should be left aligned and
I have a generic list view in Django which returns around 300 objects (unless
I have a list view in my app which shows 10 items initially, and
I have a controller which displays a list of CourseID in a view based
I have a list view which has a grid view with four columns. The
Hi have created a listbox which is bound to list of machines. As the
I have a checkbox list of sports which is bound to an observable collection

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.