Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

How to get Attachment Full URL Programatically From Sharepoint ListItem?

Explanation:

I have adding new item with attachment. Now i have to bind that attachment link to grid. When click on that link Attachment should be open.

How can i get Attachment url of that record?

share|improve this question

1 Answer 1

up vote 3 down vote accepted

I found answer for my question.

private string GetAttachmentUrls(SPListItem oItem)
{

        string path = string.Empty;

        try

        {

            path = (from string file in oItem.Attachments
                              orderby file
                              select SPUrlUtility.CombineUrl(oItem.Attachments.UrlPrefix, file)).FirstOrDefault();
            return path;
        }
        catch
        {
            return string.Empty;
        }

    }
share|improve this answer

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.