Looks like they forgot to databind the second PageList and the DropDownList.
protected override void OnLoad(System.EventArgs e)
{
base.OnLoad(e);
DataBind();
// or better:
//pl2.DataBind();
//dropdownlist.DataBind();
}
I still can't get it to work correctly. I only get the results from two page lists. This is the code I'm using.
Markup:
<EPiServer:PageList ID="pl1" runat="server" PageLink="63"/>
<EPiServer:PageList ID="pl2" runat="server" PageLink="62" DataSource="<%#pl1%>" />
Code behind:
pl2.DataBind();
epiPageList.DataSource = pl2;
epiPageList.DataBind();
If I were to add a third page list with the PageLink=61, how would I do that?
<EPiServer:PageList runat="server" PageLink="61" ID="pl1" />
<EPiserver:PageList runat="server" PageLink="62" ID="pl2" DataSource="<%#pl1%>" />
<EPiserver:PageList runat="server" PageLink="63" ID="pl3" DataSource="<%#pl2 %>"/>
<asp:DropDownList DataTextField="PageName" DataSource="<%#pl3%>" DataValueField="LinkURL" runat="server">
Will work fine. With DataBind() in your code-behind of course. But, is this just for practise, or are you trying to implement something?
I managed to get it working! I had missed the DataBind, even though you mentioned it in the other example. My typical monday...
While where on the subject; is there a way to order the final datasource by publish date? This way the news won't be displayed as you publish them unless they're in the first Page List added.
To Sort by PageStartPublish, just add SortBy="PageStartPublish" SortDirection="Descending":
<EPiServer:PageList runat="server" PageLink="61" ID="pl1" />
<EPiserver:PageList runat="server" PageLink="62" ID="pl2" DataSource="<%#pl1%>" />
<EPiserver:PageList runat="server" PageLink="63" ID="pl3" DataSource="<%#pl2 %>" SortBy="PageStartPublish" SortDirection="Descending"/>
For a list of the built in EPiServer properties, check the SDK.
Not sure I understand: "This way the news won't be displayed as you publish them unless they're in the first Page List added."
Hi,
I read an article about linking multiple page lists but I just can't get it to work. I'm trying to get the news list on the startpage from the public templates to list news from several pages. I've tried doing it just like the article says but I just can't get it to work. Sometimes I get it to show lists from two pages (when I'm using the NewsRoot-property from the template to set the PageLink) but not when doing it in code. Any ideas what I'm missing out on?
Here's the article: http://world.episerver.com/Get-Started/Developing-with-EPiServer-CMS/How-To---Continued/DropDownList-with-EPiServer-DataSource/
This is the code I'm using:
<EPiServer:PageList id="epiPageList" runat="server" Paging="True" PageLink="63">
... ...
</EPiServer:PageList>
<episerver:PageList pagelink="62" DataSource="<%#epiPageList%>" runat="server" id="pl2"/>