OrderBy Element (Query)

http://msdn.microsoft.com/en-us/library/office/ms467378.aspx

<OrderBy  Override = "TRUE" | "FALSE"  UseIndexForOrderBy = "TRUE" | "FALSE">
  <FieldRef
    Ascending = "TRUE" | "FALSE"
    Name = "Text" />
    ...
</OrderBy>

The following example sorts the fields first in ascending order by the Newcomers field, then in descending order by Years, and finally in ascending order by Location.

<OrderBy>
  <FieldRef Name="Newcomers"/>
  <FieldRef Name="Years" Ascending="FALSE"/>
  <FieldRef Name="Location"/>
</OrderBy>

Note: if the field name was changed from “Title” to something else in SharePoint, you will still need to use “Title” in your query. i.e., <FieldRef Name=”Title”/>
The field name is “InternalName” which means if it contains spaces you will need to use _x0020_ to replace the space.

Advertisements
This entry was posted in Visual Studio 2010. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s