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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C#
  4. DataView.Sort does NOTHING

DataView.Sort does NOTHING

Scheduled Pinned Locked Moved C#
questionannouncement
7 Posts 4 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.
  • C Offline
    C Offline
    Christian Graus
    wrote on last edited by
    #1

    I'm trying to sort the data in my table, but no matter what I do with the Sort property, the resultant data does not change it's order at all. Does anyone know what I'm missing ? The authors of MSDN apparently missed it too, if there's a step I need to take... DataSet comparisonDocs = facade.CompareMetadata(objectVids, elementPaths); DataView compSort = new DataView(comparisonDocs.Tables[0]); compSort.Sort="Title, Version/Major DESC, Version/Minor DESC"; comparisonRepeater.DataSource = compSort; comparisonRepeater.DataBind(); Christian I have drunk the cool-aid and found it wan and bitter. - Chris Maunder

    H R N 3 Replies Last reply
    0
    • C Christian Graus

      I'm trying to sort the data in my table, but no matter what I do with the Sort property, the resultant data does not change it's order at all. Does anyone know what I'm missing ? The authors of MSDN apparently missed it too, if there's a step I need to take... DataSet comparisonDocs = facade.CompareMetadata(objectVids, elementPaths); DataView compSort = new DataView(comparisonDocs.Tables[0]); compSort.Sort="Title, Version/Major DESC, Version/Minor DESC"; comparisonRepeater.DataSource = compSort; comparisonRepeater.DataBind(); Christian I have drunk the cool-aid and found it wan and bitter. - Chris Maunder

      H Offline
      H Offline
      Heath Stewart
      wrote on last edited by
      #2

      Is Version/Major supposed to be a field name? If so, try [Version/Major]. If you mean the Major field from the Version table, use . instead of /, although I'm not sure how that'd work in this case since your DataView is over a specific DataTable. If Version is a related table (and a DataRelation is established between the two), then use Child(_RelationshipName_)._FieldName_ which should work.

      Microsoft MVP, Visual C# My Articles

      C 1 Reply Last reply
      0
      • H Heath Stewart

        Is Version/Major supposed to be a field name? If so, try [Version/Major]. If you mean the Major field from the Version table, use . instead of /, although I'm not sure how that'd work in this case since your DataView is over a specific DataTable. If Version is a related table (and a DataRelation is established between the two), then use Child(_RelationshipName_)._FieldName_ which should work.

        Microsoft MVP, Visual C# My Articles

        C Offline
        C Offline
        Christian Graus
        wrote on last edited by
        #3

        Version/Major is indeed a field name. I didn't know that / was reserved in SQL, but I initially sorted by Title only, so I'm not sure that the [] is going to help ( it didn't sort by Title when I just specified 'Title' as the order by before ). Also, when I got the name wrong ( I'm not responsible for the schema ), and just put VersionMajor, it blew up on the basis that the column did not exist, so it presumably can see that Version/Major is a column name the way the code stands. Have you used the sort property before ? It's supposed to work just the way that I'm trying to use it, isn't it ? Christian I have drunk the cool-aid and found it wan and bitter. - Chris Maunder

        1 Reply Last reply
        0
        • C Christian Graus

          I'm trying to sort the data in my table, but no matter what I do with the Sort property, the resultant data does not change it's order at all. Does anyone know what I'm missing ? The authors of MSDN apparently missed it too, if there's a step I need to take... DataSet comparisonDocs = facade.CompareMetadata(objectVids, elementPaths); DataView compSort = new DataView(comparisonDocs.Tables[0]); compSort.Sort="Title, Version/Major DESC, Version/Minor DESC"; comparisonRepeater.DataSource = compSort; comparisonRepeater.DataBind(); Christian I have drunk the cool-aid and found it wan and bitter. - Chris Maunder

          R Offline
          R Offline
          Roman Rodov
          wrote on last edited by
          #4

          try: DataView compSort = comparisonDocs.Tables[0].DefaultView;

          C 1 Reply Last reply
          0
          • R Roman Rodov

            try: DataView compSort = comparisonDocs.Tables[0].DefaultView;

            C Offline
            C Offline
            Christian Graus
            wrote on last edited by
            #5

            Thanks, I did that. It turned out the sort was working, but the way the old code ( which I didn't write ) got it's details to render involved an array of objects instead of the data in the table... :wtf::confused: Christian I have drunk the cool-aid and found it wan and bitter. - Chris Maunder

            H 1 Reply Last reply
            0
            • C Christian Graus

              Thanks, I did that. It turned out the sort was working, but the way the old code ( which I didn't write ) got it's details to render involved an array of objects instead of the data in the table... :wtf::confused: Christian I have drunk the cool-aid and found it wan and bitter. - Chris Maunder

              H Offline
              H Offline
              Heath Stewart
              wrote on last edited by
              #6

              Glad to see you got it working. I had a reply sitting at work that I couldn't submit because the site wasn't working ("The resource is in use"). :(

              Microsoft MVP, Visual C# My Articles

              1 Reply Last reply
              0
              • C Christian Graus

                I'm trying to sort the data in my table, but no matter what I do with the Sort property, the resultant data does not change it's order at all. Does anyone know what I'm missing ? The authors of MSDN apparently missed it too, if there's a step I need to take... DataSet comparisonDocs = facade.CompareMetadata(objectVids, elementPaths); DataView compSort = new DataView(comparisonDocs.Tables[0]); compSort.Sort="Title, Version/Major DESC, Version/Minor DESC"; comparisonRepeater.DataSource = compSort; comparisonRepeater.DataBind(); Christian I have drunk the cool-aid and found it wan and bitter. - Chris Maunder

                N Offline
                N Offline
                Nick Parker
                wrote on last edited by
                #7

                Why don't you try prefixing the field with the table name followed by a period. [EDIT] Just read you got it working, sorry, I should read through everything before posting! :rolleyes: [/EDIT] - Nick Parker
                My Blog | My Articles

                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