SPQuery 未返回预期结果
我尝试使用 SPQuery 在 SharePoint 列表中搜索项目,但即使该文件在那里,结果也为空。
代码如下:
var query = new SPQuery();
query.Query = "<Where><Contains><FieldRef Name='Title' /><Value Type='Text'>" + documentTitle + "</Value></Contains></Where>";
SPListItemCollection listItems = web.Lists["ListName"].GetItems(query);
documentTitle 是现有文档的名称,“ListName”是该项目所在列表的名称。
该项目在列表中,但查询返回 0 个结果。
谁能帮我解决这个问题吗?
I am trying to search for an item in a SharePoint list using SPQuery, but even though the file is there, the result is null.
The code is the following:
var query = new SPQuery();
query.Query = "<Where><Contains><FieldRef Name='Title' /><Value Type='Text'>" + documentTitle + "</Value></Contains></Where>";
SPListItemCollection listItems = web.Lists["ListName"].GetItems(query);
documentTitle is the name of an existing document, and "ListName" is the name of the list in which the item is.
The item is in the list, but the query returns 0 results.
Can anyone help me with this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
检查以下代码..这对我有用..
Check the Following Code.. this is working for me..
这是我为使 SPQuery 编写更容易而编写的一个类。也许它能有所帮助。
https://gist.github.com/4672176
Here is a class I wrote for making SPQuery writing easier. Perhaps it can help.
https://gist.github.com/4672176