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 found a few ways to add attachments to a Data View Web Part, but I can only get this to work when the SharePoint:AttachmentsField is not being used anywhere else on the page.

Currently my DispForm.aspx page has a Custom List Form (display) for one List, and a Data View Web Part that filters its values based on the first List.

I am trying to get both the Custom List Form and the Data View Web Part to show attachments for both lists using SharePoint:AttachmentsField however I can only get one or the either to work.

Anybody have luck with this?

share|improve this question
    
Can you show the code that you have tried? –  Marc D Anderson May 16 '11 at 1:25

3 Answers 3

Looks like it is a Microsoft bug, and nothing can be done about this :(

Second AttachmentsField control on the page is always displaying this text:

["Attachments" column value]

I found that inside both controls' HTML, where is a table with static id:

<table id="idAttachmentsTable" border="0" cellSpacing="0" cellPadding="0">

So, this could be a reason for such behavour, but I'm not sure.

I tried passing to the controls all possible property values, and with no luck. And I tryed this in SharePoint 2010, and saw the same issue.

So, you should probably use another way for displaying attachments. Please, take a look at following solution:

http://www.codeproject.com/KB/sharepoint/DataViewAttachments.aspx

share|improve this answer

I added and modified the code from the editform to the last row in the dvwp on my custom dispform. Had to delete the ($Pos) parameter and remove the concat function, also changed the controlmode to display.

Diplays multiple attachments on my custom dispform.

If anyone sees a weakness with this method, please let me know

thx fran

share|improve this answer

Bad, but this may get it working? (Iframes are the devil, but if this is short term, it may meet the requirements?)

Just iframe the data view web part and overwrite the Save button to redirect the entire page on save.

Change

<input type="button" value="Save" name="btnSave" onclick="javascript: {ddwrt:GenFireServerEvent('__commit')}" />

To

<input type="button" value="Cancel This" name="btnSave" onclick="javascript: {ddwrt:GenFireServerEvent('__redirect={/redirectparent.aspx}')}" />

RedirectParent.aspx

<script>
    self.parent.location='wherever after submit.aspx';
</script>

Alternatively, if you want to look into why you can only have one on a page, It sounds like a few things

I would make sure you account for the following:

  1. Button functionality to show/hide attachments row (not necessary)
  2. Linking the attachment to the new form (very important)

I would bet its an issue with the ID's not being unique if you have two on a page. Custom List Forms probably take care of this for you.

share|improve this answer

Your Answer

 
discard

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