0

new SPAttachmentCollection is getting red what the problem? Want to display an attachment in Repeater

<%# (new SPAttachmentCollection(((SPListItem)Container.DataItem)["Attachments"].ToString()).UrlPrefix) %>
0

Morski,

Instead can you try the following:

<%# (((SPListItem)Container.DataItem).Attachments.UrlPrefix) %>

UrlPrefix property will give you only the Url Prefix part for the Attachments, you need to append the attachment file name to make complete Attachment Url...

Please follow below link:
How do I get the url for attachments on an SPListItem using C#?

  • Hi! Thanks for the help! but i get this following error on my site wingtip:49074/Lists/News-ListInstance1/Attachments/1 and not the attachment? – Batistuta Jan 23 '13 at 13:18
  • @MorskiMartin I have updated the answer! – Arsalan Adam Khatri Jan 23 '13 at 13:22
  • Hi i have tryed with this code,but dont get it to work 'private IEnumerable<string> GetAttachmentUrls(SPListItem item) { return from string fileName in item.Attachments orderby fileName select SPUrlUtility.CombineUrl(item.Attachments.UrlPrefix, fileName); } ' – Batistuta Jan 23 '13 at 13:30
  • Do it on Item databound event, instead of page file... – Arsalan Adam Khatri Jan 23 '13 at 14:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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