Displaying files from a specific folder using spdatasource

Source: Internet
Author: User

Http://www.sharepointconfig.com/2010/11/displaying-files-from-a-specific-folder-using-spdatasource/

This is a short post to show how you can use the spdatasource to display items from a specific folder in A SharePoint document library. while the other parameters are fairly well known ented on msdn this isn't very clear. generally I don't recommend the use of folders to separate data, I prefer a metadata based approach. in some cases, however, it makes sense such as when you need to manage permissions or approval for a group of documents (especially in SharePoint 2007 where you don't have document sets ). looking at the parameters we can use (as shown below) to identify and locate the data it wowould appear that passing the name of the folder to the rootfolder property wowould achieve this.

& Lt; th valign = "TOP" width = "131" & gt; Name & lt;/th & gt; & Lt; th valign = "TOP" width = "269" & gt; description & lt;/th & gt;
weburl An empty string for the root web site. Otherwise, a string containing a server-relative URL.
listname the value of the splist. Title property. You can also specify the list by setting the list property
listitemid A String representation of an integer such as the value of the splistitem. ID property.
rootfolder the value of the spfolder. Name property.

Unfortunately setting rootfolder to the name of a specific folder such as "folder1" doesn' t have any effect. The trick is to also specifyName of the list and the folderSuch as "project documents ents/folder1" as shown below:

 
<SharePoint: spdatasource ID= "Dsfolder"
 
Runat= "Server"
 
Includehidden= "True"
 
Performancemode= "List"
 
Useinternalname= "True"
Selectcommand= "& Lt; view & gt; & lt;/view & gt ;">
 
<Selectparameters>
 
<ASP: Parameter Name= "Listname" Defaultvalue= "Project documents ents" />
<ASP: Parameter Name= "Rootfolder" Defaultvalue= "Projectdocuments/folder1" />
 
</Selectparameters>
 
</SharePoint: spdatasource>

Also note that you can change the default behaviour to show both files and folders by specifying a value forScopeProperty of the spdatasource to one of the following spviewscope values:

& Lt; th valign = "TOP" width = "269" & gt; description & lt;/th & gt;
member name
default show only the files and subfolders of a specific folder.
recursive show all files of all folders.
recursiveall show all files and all subfolders of all folders.
filesonly show only the files of a specific folder.

if you need the rootfolder parameter to be dynamic (e.g. based on metadata from the current page) You can use the technique described in my previous post on creating paramem parameters for a spdatasource. if you haven't used the spdatasource control before check out the spdatasource documentation on msdn. chris o 'Brian also has a good series titled spdatasource every developers friend. it is a great way of quickly retrieving SharePoint data without writing C # code that can then be bound to ASP. net controls such as the repeater, listview, gridview or dropdownlist as well as the dataformwebpart if you want to control the output using XSLT.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.