Why does my custom filter not work in aspx templates?

HelenaG Grulichova asked on March 26, 2012 09:33

Why does my custom filter not work in aspx templates?

Correct Answer

HelenaG Grulichova answered on March 26, 2012 09:33

If you are using aspx templates, it might happen that the custom filter does not work as you are used to in the portal engine and your data is not filtered. 

<%@ Register Src="~/CustomFilters/CustomFilter.ascx" TagName="Customfilter" TagPrefix="cms" %>
<cms:Customfilter runat="server" ID="filter" FilterName="filtername" />
<cms:CustomTableDataSource runat="server" ID="datasource" SourceFilterName="filtername" CustomTable="....." />
<cms:CMSRepeater runat="server" ID="repeater" ... ></cms:CMSRepeater>

If this is your case, you will need to register the OnFilterChanged handler of the filter in the Page_Load method:

protected void Page_Load(object sender, EventArgs e)
{
  filter.OnFilterChanged += new CMS.Controls.ActionEventHandler(filter_OnFilterChanged);
  repeater.DataSource = datasource.DataSource;
  repeater.DataBind();
}

and within the handler, bind the repeater control with the datasource as demonstrated here:

void filter_OnFilterChanged()
{
  repeater.DataSource = datasource.DataSource;
  repeater.DataBind();
}

Other resources: Custom filter development
 
-ml-
0 votesVote for this answer Unmark Correct answer

   Please, sign in to be able to submit a new answer.