Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I have document library which have folder and sub folder. the folder and sub folder level is more than 5. like as follow :

Document Library
   |-> Folder-1
   |   -> Folder-1-1
   |      -> Folder-1-1-1
   |         -> Folder-1-1-1-1
   |            -> Folder-1-1-1-1-1
   |               -> Document1.doc
   -> Folder-2
   |   -> Folder-2-1
   |      -> Folder-2-1-1
   |         -> Folder-2-1-1-1
   |            -> Folder-2-1-1-1-1
   |               -> Document2.doc

now i want a CAML Query that search the document from all folders of document library and list them in grid view. if i search "men" then it will display documents in Grid view which contains "men" in there Title Field

share|improve this question
add comment

1 Answer

up vote 0 down vote accepted

Your CAML query should look like this:

<Query>
   <Where>
      <Contains>
         <FieldRef Name='FileLeafRef' />
         <Value Type='File'>men</Value>
      </Contains>
   </Where>
</Query>

And specify the ViewAttribute of SPQuery to Recursive so that documents within folders are also displayed. oQuery.ViewAttributes = "Scope=\"Recursive\"";

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.