Problem with Listview Column Sorting (numbers not getting sorted properly) ...


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 7 of 7

Thread: Problem with Listview Column Sorting (numbers not getting sorted properly) ...

  1. #1
    Join Date
    Jun 2006
    Posts
    29

    Problem with Listview Column Sorting (numbers not getting sorted properly) ...

    Hello!

    I'm trying to sort the data in a Listview that contains the list of Files/Folders along with their sizes in sub-item. I want to sort the listview content based on Size. However, I found that Listview control does not recognize the numeric data as Numbers and it treats it as Strings while attempting to sort. I found that number 9.1 is shown above 81! This is not a correct sorting, right? Is there any solution for this?

    To make my query clear, I have created a small Demo program. Please see the code, run the program and you will realize what I'm talking about. Is there any solution for this? I'm not finding any. I have attached the code to this comment.

    Waiting for your reply ...

    Regards,

    Ruturaj.
    Attached Files Attached Files

  2. #2
    Join Date
    Dec 2005
    Posts
    92
    vb_programmer,click the thread created by Vidhi - Sorting numeric data in listview.I've an answer posted there.See if it helps you.

  3. #3
    Join Date
    Jun 2006
    Posts
    29
    Yeh! This one helped me ... it works perfect! By the way, I also need to sort the data based on File Creation Date. Is there any this sort of fantastic trick for sorting content on the basis of Date? Currently I write the data to Subitem in the form of mm-dd-yyyy. Is there any such fantastic trick to sort the data based on Date. The Date format is not a binding and to make the sorting possible, no problem if I need to change it to anything else.

    Waiting for your valuable reply ...

    -- Ruturaj.

  4. #4
    Join Date
    Nov 2003
    Location
    Alameda, CA
    Posts
    1,737
    format the date as "yyyy-mm-dd"
    "There are two ways to write error-free programs. Only the third one works."
    Unknown

  5. #5
    Join Date
    Jun 2006
    Posts
    29
    Thanks mstraf! I will try it and will let you know if it worked fine or otherwise.

  6. #6
    Join Date
    Dec 2005
    Posts
    92
    vb_programmer,it seems you've not tested it yourself but the date field will be sorted as it is.You do not have to resort to the technique for the numeric column.Give it a try.

  7. #7
    Join Date
    Jun 2006
    Posts
    29
    Yes, I tried it and in my test the files with date 02/03/2004 appeared above 03/14/2003!

Similar Threads

  1. Stored Procedure column Name problem
    By david in forum Database
    Replies: 2
    Last Post: 01-07-2003, 01:47 PM
  2. Replies: 1
    Last Post: 03-06-2002, 10:56 AM
  3. Replies: 0
    Last Post: 10-02-2001, 08:29 AM
  4. Replies: 3
    Last Post: 02-21-2001, 07:28 AM
  5. CrossBrowser DHTML table sorting problem
    By Joel Matto in forum Web
    Replies: 0
    Last Post: 05-02-2000, 03:58 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center