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?