Document Attachment From Code Behind Path issue

Rahul Raghuvanshi asked on August 14, 2015 10:21


I am working on developing Page application with Kentico version 8.

I have integrated product module in my application, in CMS.Product created a custom field "Manuals" of PageAttachment type.

I have created an custom webpart in which I need to display attachments using Document attachment webpart within Repeater item template from code.

Here is my .aspx repeater code:

                   <asp:Repeater ID="rptProducts"   runat="server" OnItemDataBound="rptProducts_ItemDataBound">

                                <span>Model #</span>
                                <span>Wall Ovens</span>
                                <span>Show/Hide Downloads</span>
                <div class="product-downloads-product" id="div<%#(Container.ItemIndex +1)%>">
                                <div class="product-downloads-description">
                                    <span><%#Eval("SerialNumber") %></span>
                                    <span><%#Eval("SKUName") %></span>

                                    <span class="show-downloads" data-toggle=".product-downloads-list" data-toggle-siblings=".product-downloads-product" onclick="ShowHide(<%#(Container.ItemIndex +1)%>)">Show Downloads</span>

                                <ul class="product-downloads-list" id="ul<%#(Container.ItemIndex +1)%>">
                                    <cms:DocumentAttachments ID="pageAttachments" Path='<%#Eval("NodeAliasPath")%>' AttachmentGroupGUID="bc09f4fe-cad1-4c37-ac33-2b41e3bf8b8f" runat="server" TransformationName="Decore.Transformation.Product_DisplayDownloads" />



I am populating my repeater from code behind from Product data set, in repeater transformation displaying Product Name, Series column value and NodeAliasPath containing Path of each product. Need to get all the attachments of each products using Product NodeAliasPath as Path of Document attachment web part.

When running above code, it seems Path value going blank that is taking from '<%#Eval(NodeAliasPath)%>'.

I have checked <%#Eval(NodeAliasPath)%> its giving correct value of each product path, even I tried to bind Document attachment webpart Path into Repeater ItemDataBound event also, value assigning correctly but seems to not reaching at the time of assigning to document attachment webpart, its taking blank.

If I set document attachment Path value hard coded Product Node Alias Path into directly document attachment tag page it works fine. Like:

<cms:DocumentAttachments ID="pageAttachments" Path="/Products/Ranges/Discovery-48-Dual-Fuel-Range" AttachmentGroupGUID="bc09f4fe-cad1-4c37-ac33-2b41e3bf8b8f" runat="server" TransformationName="Decore.Transformation.Product_DisplayDownloads" />

Please help me where I am doing wrong or missed any thing to set.

Thanks in advance.

Recent Answers

David te Kloese answered on August 14, 2015 11:11


you might want to try reloading the DocumentAttachments data, after the repeater has its item databound.


1 votesVote for this answer Mark as a Correct answer

Rahul Raghuvanshi answered on August 14, 2015 14:41

Hello David,

Thanks for your reply.

If I understood you correct, you want me to call Reload() method of DocumentAttachment. Like: objDocumentAttachment.ReloadData();

Where should I write this code, in Repeater ItemDataBound event or somewhere else?

0 votesVote for this answer Mark as a Correct answer

David te Kloese answered on August 15, 2015 23:38

Hi Rahul,

Indeed i'd say add a OnItemDataBound event to the repeater. When hit find your DocumentAttachments and call its ReloadData().


1 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.