Had this question pop up at work today, to show all items without folders in SharePoint you will need to add the Recursive attribute to the SPQuery object.

 Here is an example, This can be done in Code:

 SPQuery.ViewAttributes += ” Scope=\”Recursive\””;

 Or as part of the CAML Query Markup

    <FieldRef Name=’ID’ /> 

</ViewFields> 

<QueryOptions> 

   <ViewAttributes Scope=’Recursive’ /> 

   <OptimizeFor>FolderUrls</OptimizeFor> 

</QueryOptions>

Other query options are:

<QueryOptions>
   <IncludeMandatoryColumns>True</IncludeMandatoryColumns>
   <DateInUtc>True</DateInUtc>
   <IncludeAttachmentUrls>True</IncludeAttachmentUrls>
   <IncludePermissions>True</IncludePermissions>
   <ExpandUserField>True</ExpandUserField>
   <Folder>Name Of the Folder Here/</Folder>
</QueryOptions>

Advertisements