帮助使用 CAML 查询访问文档库中的文档类型

发布于 2024-10-09 20:21:58 字数 806 浏览 0 评论 0 原文

我在 SharePoint 上有一个文档库,其中托管不同类型的文档,并且我有一个自定义搜索 Web 部件,该部件应该搜索库并根据搜索类型以及其他搜索条件显示文档。问题是我无法搜索文档类型,我的 CAML 查询如下:

           SPWeb web = site.OpenWeb();
           SPList document = web.Lists["Training Docs"];
           SPListItemCollection objItemcoll;
           SPQuery objQuery = new SPQuery();
           objQuery.Query = "<Where><Contains><FieldRef Name=\"Name\"/>
           <Value Type=\"Text\"></Value>doc</Contains></Where>";
           objItemcoll = document.GetItems(objQuery);
           if (objItemcoll.Count > 0)
           {
               foreach (SPListItem item in objItemcoll)
               {
                   //Binding To Grid;
               }
           }
       }

我猜测故障出在 value type=" " 。任何帮助将不胜感激。

I have a Document Library on SharePoint which hosts documents of different types and i have a custom search web part which is supposed to search the library and display documents based on search type along with other search criteria.Problem is i cant search for the document type, My CAML query is as follows:

           SPWeb web = site.OpenWeb();
           SPList document = web.Lists["Training Docs"];
           SPListItemCollection objItemcoll;
           SPQuery objQuery = new SPQuery();
           objQuery.Query = "<Where><Contains><FieldRef Name=\"Name\"/>
           <Value Type=\"Text\"></Value>doc</Contains></Where>";
           objItemcoll = document.GetItems(objQuery);
           if (objItemcoll.Count > 0)
           {
               foreach (SPListItem item in objItemcoll)
               {
                   //Binding To Grid;
               }
           }
       }

Im guessing the fault is with value type=" " . Any help would be appreciated.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

娇俏 2024-10-16 20:21:58

尝试:

<Where><Contains><FieldRef Name='FileLeafRef' /><Value Type='Text'>doc</Value></Contains></Where>

我使用 U2U CAML 查询生成器 创建了此查询。你可能想尝试一下。它是用于为 SPQuery 对象创建 CAML 查询字符串的资源。

Try:

<Where><Contains><FieldRef Name='FileLeafRef' /><Value Type='Text'>doc</Value></Contains></Where>

I created this query using the U2U CAML Query Builder. You might want to try it. It is the resource for creating CAML query strings for SPQuery objects.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文