November Happy Hour will be moved to Thursday December 5th.

Problem with linking multiple page lists

Vote:
 

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"/>

#35159
Nov 30, 2009 14:07
Vote:
 

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();
}

#35174
Edited, Nov 30, 2009 17:55
Vote:
 

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?

#35183
Nov 30, 2009 18:33
Vote:
 

<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?

#35187
Nov 30, 2009 19:03
Vote:
 

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.

#35188
Nov 30, 2009 19:08
Vote:
 

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."

#35192
Nov 30, 2009 19:18
Vote:
 

I might have had a bad day but maan I need to start looking before asking... ;)

Thanks! Once again you saved the day.

#35219
Dec 01, 2009 8:01
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.