我想要Pdf
这个模块中的一个字段。我想获得 pdf 完整的 url 和名称,但不知道如何在 sitefinity 中执行。有人可以帮助我吗?
ASP.X
<asp:Repeater ID="rptList" runat="server" OnItemDataBound="rptList_ItemDataBound">
<HeaderTemplate>
</HeaderTemplate>
<ItemTemplate>
<asp:Label ID="lblTitle" runat="server" Text='<%# Eval("Title") %>'></asp:Label>
<asp:Label ID="lblSummary" runat="server" Text='<%# Eval("Content") %>'></asp:Label>
<div>
<asp:Repeater ID="rptPdfList" runat="server" >
<HeaderTemplate>
</HeaderTemplate>
<ItemTemplate>
<li>
<asp:HyperLink ID="hlSubMenu" runat="server" Text='<%# Eval("Name") %>' NavigateUrl='<%# Eval("Url") %>'
onclick='return handleHyperLinkClick(this)'></asp:HyperLink>
</li>
</ItemTemplate>
<FooterTemplate>
</FooterTemplate>
</asp:Repeater>
</div>
</ItemTemplate>
<FooterTemplate>
</FooterTemplate>
</asp:Repeater>
。CS
private Guid guid { get; set; }
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
string id = Request.QueryString["id"];
guid = new Guid(id);
var myCollection = GetDataItems();
rptList.DataSource = myCollection;
rptList.DataBind();
}
}
public IQueryable<DynamicContent> GetDataItems()
{
DynamicModuleManager dynamicModuleManager = DynamicModuleManager.GetManager();
Type newsReleasesType = TypeResolutionService.ResolveType("Telerik.Sitefinity.DynamicTypes.Model.NewsReleases.NewsReleases");
var myCollection = dynamicModuleManager.GetDataItems(newsReleasesType).Where(i => i.Status == Telerik.Sitefinity.GenericContent.Model.ContentLifecycleStatus.Live && i.Id == guid);
return myCollection;
}
protected void rptList_ItemDataBound(object sender, RepeaterItemEventArgs e)
{
DataTable dtChildNodes = new DataTable();
dtChildNodes.Columns.Add("Name", typeof(string));
dtChildNodes.Columns.Add("Url", typeof(string));
var myCollection = GetDataItems();
foreach (var mp in myCollection)
{
ContentLink cl = ((ContentLink[])mp.GetValue("Pdf"))[0];
dtChildNodes.Rows.Add(cl.ChildItemProviderName, cl.ChildItemAdditionalInfo);
}
Repeater rpt = (Repeater)e.Item.FindControl("rptPdfList");
rpt.DataSource = dtChildNodes;
rpt.DataBind();
}