SharePoint:如何使用 CAML 查询从列表中获取前 5 条记录 [英] SharePoint: How to get Top 5 records by using CAML query from a list
本文介绍了SharePoint:如何使用 CAML 查询从列表中获取前 5 条记录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我已经创建了一个 webpart 来显示列表中的数据,但我真正想要的是只显示该列表中的前 5 条记录(通过使用 CAML 查询).
I have already created a webpart to show the data from list, but I really want is to only show top 5 records from that list (by using CAML query).
有人知道怎么做吗?非常感谢.
Does anyone know how to do this? Many thanks.
<Query>
<OrderBy>
<FieldRef Name='ID' Ascending='False' />
</OrderBy>
</Query>
推荐答案
您可以设置 SPQuery 对象的 RowLimit 属性.
You could set the RowLimit property of your SPQuery object.
标记位于视图的架构定义中(<View>
的直接子级),因此不能嵌套在 中
标签.
The <RowLimit>
tag is in the schema definition of a view (direct child of <View>
) and therefore cannot be nested inside a <Query>
tag.
这篇关于SharePoint:如何使用 CAML 查询从列表中获取前 5 条记录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文