Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. Sort column in datatable

Sort column in datatable

Scheduled Pinned Locked Moved Visual Basic
question
5 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • H Offline
    H Offline
    helelark123
    wrote on last edited by
    #1

    Hello, I am programming in VB2005 I have a DataColumn with numbers and '<' sign as following: -10 -5 <-90 <-50 +2 How can I sort this column? Should I add another hided column and sort it? Is there another way to do this?

    Shay Noy

    J 1 Reply Last reply
    0
    • H helelark123

      Hello, I am programming in VB2005 I have a DataColumn with numbers and '<' sign as following: -10 -5 <-90 <-50 +2 How can I sort this column? Should I add another hided column and sort it? Is there another way to do this?

      Shay Noy

      J Offline
      J Offline
      Johan Hakkesteegt
      wrote on last edited by
      #2

      I suppose the column is of type string (nvarchar/nchar/varchar/etc). How do you want this column to be sorted? In other words, what should the order be in the example you posted?

      My advice is free, and you may get what you paid for.

      H 1 Reply Last reply
      0
      • J Johan Hakkesteegt

        I suppose the column is of type string (nvarchar/nchar/varchar/etc). How do you want this column to be sorted? In other words, what should the order be in the example you posted?

        My advice is free, and you may get what you paid for.

        H Offline
        H Offline
        helelark123
        wrote on last edited by
        #3

        Like this: <-90 'Smaller than -90 <-50 'Smaller than -50 and that mean that it is bigger that <-90 -10 -5 +2

        Shay Noy

        J 1 Reply Last reply
        0
        • H helelark123

          Like this: <-90 'Smaller than -90 <-50 'Smaller than -50 and that mean that it is bigger that <-90 -10 -5 +2

          Shay Noy

          J Offline
          J Offline
          Johan Hakkesteegt
          wrote on last edited by
          #4

          You said that you are allowed to add a new column, so I assume that you are free to adapt the table structure. If I were you, I would separate the < and > type characters from this column into its own column. Then transform the original column to type int, and simply adapt any queries or code to take both columns into account instead of only the one. This means that you may have to adapt the query that got the data into this column to begin with, so that it separates the two value types (integers and < / >).

          My advice is free, and you may get what you paid for.

          H 1 Reply Last reply
          0
          • J Johan Hakkesteegt

            You said that you are allowed to add a new column, so I assume that you are free to adapt the table structure. If I were you, I would separate the < and > type characters from this column into its own column. Then transform the original column to type int, and simply adapt any queries or code to take both columns into account instead of only the one. This means that you may have to adapt the query that got the data into this column to begin with, so that it separates the two value types (integers and < / >).

            My advice is free, and you may get what you paid for.

            H Offline
            H Offline
            helelark123
            wrote on last edited by
            #5

            Thank you

            Shay Noy

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups