OrderBy Element (Query)


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

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.

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

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.

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 )

Google+ photo

You are commenting using your Google+ 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 )


Connecting to %s