Friday, June 19, 2009

Showing Attachments in List Views

Came across this one for one of my custmers. Wants an ability to upload documents to a list item and then show the uploaded docuuments on the list view.
The solution here is to use Attachments and try to get them to show on the view. By default the Attachments field will only give back a true/false value of 0/1, which is only useful for highlighting the fact that there are attachments.
You can build SharePoint Controls into your views and the one you need to show all the attachments as links is the AttachmentField



<SharePoint:AttachmentsField ControlMode="Display" ItemId="{@ID}" FieldName="Attachments" runat="server"/>

2 comments:

Jessica said...

where exactly would you put this code? I have an out of the box Email List View, and I want to be able to show an "Attachments" column. Please advise. Thanks in advance!

alx said...

Ah, so sorry. I should have been more precise.
This only works when you convert your view into an XSLT Dataview using SharePoint Designer.
Simply right click on the view in SPD and you should get the convert to xslt option. Once converted you can do many wonderful things including adding such controls.