开发者

Help with CAML query for accessing document types in document library

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 i开发者_如何学Ctem in objItemcoll)
               {
                   //Binding To Grid;
               }
           }
       }

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


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜