none
Need help in CAML Query - Sort Operation RRS feed

  • Question

  • hi

    I have a list column "DisplayOrder" in which i have integer values, i am using this query

    <Query><OrderBy><FieldRef Name="DisplayOrder" Ascending="True" /></OrderBy></Query>

    this returns me listcollection

    1

    10

    15

    2

    it is considering the colums as string, can i convert this column to integer before sorting?

    i want this result

    1

    2

    10

    15

    Thursday, September 2, 2010 10:50 AM

Answers

  • Shafaqat,

       It sounds like your DisplayOrder column type is set to contain strings or text instead of numbers.  If you open the list and navigate to Settings -> List Settings then scroll down to Columns, what is the type next to DisplayOrder?  If it is "single line of text" or some other string type you can switch the type.  Click the name of your column and change the type to "Number (1, 10, 100)" and click OK.  You will receive a message about possible loss of data (make sure to have a backup of your list first if this is important data) and click OK on the popup.  When you query your list now you should receive numerical sorting instead of alphabetical.

    -Brian T. Jackett

    MCTS: SPS2010 Configuring, SPS2010 App Dev, WSS 3.0 App Dev, MOSS 2007 App Dev, MOSS 2007 Config, Project Server 2007 Config

    Thursday, September 2, 2010 2:04 PM

All replies

  • Shafaqat,

       It sounds like your DisplayOrder column type is set to contain strings or text instead of numbers.  If you open the list and navigate to Settings -> List Settings then scroll down to Columns, what is the type next to DisplayOrder?  If it is "single line of text" or some other string type you can switch the type.  Click the name of your column and change the type to "Number (1, 10, 100)" and click OK.  You will receive a message about possible loss of data (make sure to have a backup of your list first if this is important data) and click OK on the popup.  When you query your list now you should receive numerical sorting instead of alphabetical.

    -Brian T. Jackett

    MCTS: SPS2010 Configuring, SPS2010 App Dev, WSS 3.0 App Dev, MOSS 2007 App Dev, MOSS 2007 Config, Project Server 2007 Config

    Thursday, September 2, 2010 2:04 PM
  • Hi ,

    I am facing the same problem and I have tried after changing the type to number. But still I didn't get in order.


    • Edited by mbksp Tuesday, November 12, 2013 12:06 PM
    Tuesday, November 12, 2013 12:05 PM