Try our conversational search powered by Generative AI!

Filtering PageList

Vote:
 

Front-end developer here and trying to achieve something without resorting to the code-behind. I'm using CMS6

I have a PageList control that I'd like to only display pages that meet a specific requirement. So, my content tree looks like this...

Root folder
  Home
    Top
      Page1
      Page2
      Page3
      etc

Page1, Page2, ... each have a "Dynamic list (multiple options)" property called "Flag". When that property is set to "A", I want it to display in the PageList.

Here's what I am trying, but results in a "Object reference not set to an instance of an object."

<EPiServer:SearchDataSource PageLink="5" runat="server" ID="ListDS" >
  <SelectParameters>
    <EPiServer:PropertyParameter Name="PageLink" PropertyName="Flag"  />
  </SelectParameters>
</EPiServer:SearchDataSource>

<EPiServer:PageList SortBy="PageName" DataSource="<%# ListDS %>" runat="server" ID="t1_list">
  <ItemTemplate>
    ...
  </ItemTemplate>
</EPiServer:PageList>

 

Is the searchdatasource the right approach? I've searched high and low for examples on how to use it, but the only example is how to use it when the query parameter is coming from an element on the page. I did find an article, http://tednyberg.com/post/Search-for-EPiServer-pages-based-on-properties.aspx, but the page doesn't come up.

thanks in advance

#39115
May 04, 2010 17:28
Vote:
 

You can set specific parameters for the SearchDataSource. Try something like this:

<EPiServer:SearchDataSource>
<Criteria>
    <EPiServer:PropertyCriteriaControl Condition="Equal" Name="Flag" Value="A" />
</Criteria>
</EPiServer:SearchDataSource

#39136
May 04, 2010 22:10
Vote:
 

Thanks Per,

Any thoughts as to why I'd be getting the following error message?

Unable to cast object of type 'EPiServer.Web.WebControls.SearchDataSource' to type 'System.Collections.IEnumerable'.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.InvalidCastException: Unable to cast object of type 'EPiServer.Web.WebControls.SearchDataSource' to type 'System.Collections.IEnumerable'.

#39235
Edited, May 05, 2010 20:19
Vote:
 

You cant use SearchDataSource with a pagelist. Use a repeater instead.

The pagelist datasource expects a control that contains a pagedatacollection and implements the IEnumerable interface.

/Per

#39236
May 05, 2010 21:50
Vote:
 

Can I use <episerver:property> controls from within an asp:repeater?

#39237
May 05, 2010 22:06
Vote:
 

Yep :)

#39238
May 05, 2010 23:47
This thread is locked and should be used for reference only. Please use the Episerver CMS 7 and earlier versions forum to open new discussions.
* 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.