从共享点列表中检索附件的URL

时间:2012-11-28 11:58:38

标签: c# sharepoint-2010

我们使用spquery对象从列表中检索一些项目并填充转发器。我需要抓住附件的网址。我已将IncludeAttachmentUrls设置为true,但我不确定要在转发器中使用的字段名称。

     SPWeb Web = SPContext.Current.Web;
     SPList List = Web.Lists["LinksList"];

     SPQuery Query = new SPQuery();
     Query.Query = "<OrderBy><FieldRef Name='Title' Ascending='False' /></OrderBy>";
     Query.IncludeAttachmentUrls = true;

     RPTLinks.DataSource = List.GetItems(Query).GetDataTable();
     RPTLinks.DataBind();

2 个答案:

答案 0 :(得分:0)

我希望这可能会对您有所帮助,它不是一个功能齐全/经过全面测试的解决方案,但可能会让您领先:

foreach循环和oItem.url是我在CAML查询后最常使用的。

     SPList List = Web.Lists["LinksList"];

     SPQuery Query = new SPQuery();
     Query.Query = "<OrderBy><FieldRef Name='Title' Ascending='False' /></OrderBy>"
ArrayList values = new ArrayList();

foreach (SPListItem oItem in oList.GetItems(Query))
{
values.Add(oItem.Url);

// You might need to add extra code here to get the full path if you need to such as spweb url etc..

}
RPTLinks.DataSource = values;

RPTLinks.DataBind();

答案 1 :(得分:0)

该属性称为Attachments,但还需要一个额外的操作来获取每个属性的完整URL。在SharePoint StackExchange上查看此question