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've got a single item DVWP (in a web part zone) displaying items from a list (gets the ID of the item to display from a query string parameter), it also displays any attachments using this;

            <xsl:element name="SharePoint:AttachmentsField">
                <xsl:attribute name="runat">server</xsl:attribute>
                <xsl:attribute name="ListId">{C0FB9150-7B78-4831-9098-8CE6CD7D31F3}</xsl:attribute>
                <xsl:attribute name="FieldName">Attachments</xsl:attribute>
                <xsl:attribute name="ControlMode">Display</xsl:attribute>
                <xsl:attribute name="Visible">true</xsl:attribute>
                <xsl:attribute name="ItemId"><xsl:value-of select="@ID"/></xsl:attribute>
            </xsl:element>

We have the problem that when the page the DVWP is in draft, it displays the correct attachments for all items.

When the page is published it will display the correct attachments for the first item you view, then go on to show those same attachments for all other items. It will 'reset' itself when recycle the app pool.

Any help would be appreciated.

Thanks,

Dan.

share|improve this question

1 Answer 1

The code you have there is good only for single item view. It will only show the first item from a multi-item view, which is what you are seeing happen when you publish.

The solution is to add this code before your code:

<xsl:element name="SharePoint:AttachmentButton">
    <xsl:attribute name="ControlMode">Edit</xsl:attribute>
    <xsl:attribute name="Enabled">true</xsl:attribute>
    <xsl:attribute name="ItemId">{@ID}</xsl:attribute>
    <xsl:attribute name="runat">server</xsl:attribute>
    <xsl:attribute name="Visible">false</xsl:attribute>
</xsl:element>

That should give you any and all attachements for multiple items.

share|improve this answer
    
We are using a single item view. Unfortunately this doesn't resolve the problem. –  dan Mar 9 '11 at 4:10

Your Answer

 
discard

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

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