0

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

1 Answer 1

0

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\"";

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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