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'm working to show my attachments in a repeater control. It works ALMOST perfectly. I just want to get the full url to my attachment. Right now i'm getting: http://knowitintranet:9797/sites/News/Lists/KnowIT.News-ListInstance1/Attachments/1/ but i want it to show http://knowitintranet:9797/sites/News/Lists/KnowIT.News-ListInstance1/Attachments/1/banana.jpg

The aspx code i'm currently using is:

<a href="<%# ((SPListItem)Container.DataItem).Attachments.UrlPrefix %> " target="_blank"><%# ((SPListItem)Container.DataItem).Attachments[0] %></a>

This is my buttonclick event code:

    protected void ButtonChoose_Click(object sender, EventArgs e)
    {
        try
        {
            using (SPSite site = new SPSite("http://knowitintranet:9797/sites/News"))
            {
                SPWeb web = SPContext.Current.Web;
                SPList list = web.Lists.TryGetList(DropDownListCategory2.SelectedItem.Value);

                SPQuery query = new SPQuery();
                query.Query = "<OrderBy><FieldRef Name='Modified' Ascending='FALSE' /></OrderBy>";
                query.IncludeAttachmentUrls = true;
                query.RowLimit = 3;

                SPListItemCollection items = list.GetItems(query);

                RepeaterContent.DataSource = items;
                RepeaterContent.DataBind();
            }
        }
        catch (Exception)
        {
            LabelException.Text = LabelException.Text =  "";
        }
    }

Any suggestions?

share|improve this question

1 Answer 1

There are can be several attachments. I think that you can use second repeater in your fist repeater to show all attachments. How to get correct URLs for the attachments you can see in this thread.

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.