Monday, May 3, 2010

SPQuery

Get specific, ordered items from lists

SPWeb curweb = SPContext.Current.Web;
SPList curlist = curweb.Lists[lst_guid];

SPQuery query = new SPQuery();
query.Query = "<OrderBy><FieldRef Name='Modified' Ascending="false" /></OrderBy>";
query.RowLimit = 5;
SPListItemCollection items = curlist.GetItems(query);

foreach (SPListItem lst in items)

{
//do stuff with received items
}

http://www.aidangarnish.net/post/Using-SPQuery-and-CAML-to-filter-and-order.aspx

http://social.msdn.microsoft.com/Forums/en/sharepointdevelopment/thread/e55d53eb-d11c-470e-b064-1c12ab788706

No comments:

Post a Comment