[英]Retrieve the first list item of a sorted list SharePoint 2010 C#
我今天才开始进行SharePoint Webpart编程。 我有一个名为“ pagesList”的列表,我想使用字段“ sortField”以降序对其列表项进行排序。 然后,我想获得列表中的第一项。 这是我到目前为止尝试过的方法,但是我不知道如何获取已排序列表中的第一项来分配它。
if (pagesList != null)
{
SPQuery q = new SPQuery();
q.Query = "<OrderBy><FieldRef Name='sortField' Ascending='False' /></OrderBy>";
SPListItemCollection listItemCollection = pagesList.GetItems(q);
CurrentIssueLinkButton.PostBackUrl = /* the first item of the sorted listitems goes here*/;
}
如何获得第一个列表项?
将SPQuery对象的RowLimit
设置为1,以确保最多返回一项。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.