Hello,
I have a simple but working search function but want change the result sort order by selecting a new sorting from a drop down. The problem is that the result list does not seems to update every time I change drop down selection. Why? Is it some kind of cache problem?
from search.aspx:
<%# getpreviewtext(container.dataitem as episerver.core.pagedata) %>
%#>
and from the search.aspx.cs
protected void SortDropDownList_Changed(object sender, EventArgs e)
{
System.Web.UI.WebControls.DropDownList sortDropDown = (System.Web.UI.WebControls.DropDownList)sender;
// public enum FilterSortOrder
// ---------------------------
// Alphabetical Sorted alphabetical on name
// ChangedDescending Most recently changed page will be first in list
// CreatedAscending Oldest created page will be first in list
// CreatedDescending Most recently created page will be first in list
// Index Sorted on page index
// None
// PublishedAscending Oldest published page will be first in list
// PublishedDescending Most recently published page will be first in list
// Rank Sort on ranking, only supported by special controls
switch (sortDropDown.SelectedValue)
{
case "Alphabetical":
SearchResult.SortOrder = EPiServer.Filters.FilterSortOrder.Alphabetical;
break;
case "AlphabeticalDescending":
SearchResult.SortOrder = EPiServer.Filters.FilterSortOrder.Alphabetical;
SearchResult.SortDirection = EPiServer.Filters.FilterSortDirection.Descending;
break;
case "CreatedDescending":
SearchResult.SortOrder = EPiServer.Filters.FilterSortOrder.CreatedDescending;
break;
case "CreatedAscending":
SearchResult.SortOrder = EPiServer.Filters.FilterSortOrder.CreatedAscending;
break;
}
}
thanx
Om Du använder en PageSearch för att presentera resultatet, så finns det en egenskap där för sortering
SearchResults.SortBy = drpSort.SelectedValue.ToString();
I listboxen har jag egenskaper på sidan
Senast startatSenast avslutat
Thank you for the reply Helena, however, my problem seems to be that the EPiServer:PageList is not updated correctly. PageList too has a SortBy property (though I am using SortOrder and SortDirection), but it only change the sort sometimes. Perhaps due to cache?
<%# getpreviewtext(container.dataitem as episerver.core.pagedata) %> %#>
protected void SortDropDownList_Changed(object sender, EventArgs e) { System.Web.UI.WebControls.DropDownList sortDropDown = (System.Web.UI.WebControls.DropDownList)sender; // public enum FilterSortOrder // --------------------------- // Alphabetical Sorted alphabetical on name // ChangedDescending Most recently changed page will be first in list // CreatedAscending Oldest created page will be first in list // CreatedDescending Most recently created page will be first in list // Index Sorted on page index // None // PublishedAscending Oldest published page will be first in list // PublishedDescending Most recently published page will be first in list // Rank Sort on ranking, only supported by special controls switch (sortDropDown.SelectedValue) { case "Alphabetical": SearchResult.SortOrder = EPiServer.Filters.FilterSortOrder.Alphabetical; break; case "AlphabeticalDescending": SearchResult.SortOrder = EPiServer.Filters.FilterSortOrder.Alphabetical; SearchResult.SortDirection = EPiServer.Filters.FilterSortDirection.Descending; break; case "CreatedDescending": SearchResult.SortOrder = EPiServer.Filters.FilterSortOrder.CreatedDescending; break; case "CreatedAscending": SearchResult.SortOrder = EPiServer.Filters.FilterSortOrder.CreatedAscending; break; } }
thanx