Paging does not work in the current code for PostList (CS2007.1). I fixed it by deriving PostQueryWithType from PostQuery and calling ApplyQueryOverrides in PostList in the same manner that SectionList does with the SectionQuery object. I have two questions about this:
PostQuery.ApplyQueryOverrides takes in a ThreadQuery object as it's parameter. Shouldn't that be a PostQuery Object? I had to create my own version of ApplyQueryOverrides taking a PostQuery object in PostQueryWithType because I can't pass in an abstract ThreadQuery object on PostList.cs.
I also want to know if this is the correct way to fix this problem. I can pass my code along if someone wants to check it out.
Charles,
If you wouldnt mind i would like to take a look at what you did because I have found that paging and other overides dont work with CurrentUserFavorites and have been looking for a fix.
Thanks
Shakes
peace shakes
Carolina Pulse
My changes are bold and highlighted in gray
PostQueryWithType.cs:
using System; using System.Collections.Generic; using System.Text; using CommunityServer.Components; using System.Web.UI; // CAB: Custom - Bug Fix for post list paging - derives from PostQuery now // - Compare with changeset 229 for code differences namespace CommunityServer.Controls { /// <summary> /// Query options for accessing Post objects. /// </summary> public class PostQueryWithType : PostQuery { #region Public Properties /// <summary> /// Gets or sets the index of the page of objects to display. This value is overridden when a PagerID is specified. /// </summary> /// <value>The index of the page to display.</value> public override int PageIndex { get { object val = ViewState["PageIndex"]; return val == null ? 0 : (int)val; } set { ViewState["PageIndex"] = value; if (this.Pager != null) this.Pager.PageIndex = value; } } /// <summary> /// Gets or sets the number of objects to show on a single page. /// </summary> /// <value>The size of the page.</value> public override int PageSize { get { object val = ViewState["PageSize"]; return val == null ? 15 : (int)val; } set { ViewState["PageSize"] = value; } } /// <summary> /// Gets or sets the ID of the IPager control to use to control the current PageIndex. /// </summary> /// <value>The pager ID.</value> public override string PagerID { get { return ((string)ViewState["PagerID"]) ?? string.Empty; } set { ViewState["PagerID"] = value; } } private IPager _pager = null; /// <summary> /// Gets or sets the IPager control used to control the current PageIndex. /// </summary> /// <value>The pager.</value> public override IPager Pager { get { if (_pager == null && !string.IsNullOrEmpty(PagerID)) _pager = CSControlUtility.Instance().FindControl(this, PagerID) as IPager; return _pager; } set { _pager = value; PagerID = ((Control)_pager).ID; } } /// <summary> /// Gets or sets the type of this query; the generic location/relationship from which data will be retrieved. /// </summary> /// <value>The type of the query.</value> public PostQueryType QueryType { get { object var = ViewState["QueryType"]; return var == null ? PostQueryType.Default : (PostQueryType)var; } set { ViewState["QueryType"] = value; } } #endregion #region Apply Overrides method /// <summary> /// Applies the query overrides to the underlying query. /// </summary> /// <param name="query">The query.</param> public virtual void ApplyQueryOverrides(PostQueryWithType query) { if (Pager != null) this.PageIndex = Pager.PageIndex; if (ViewState["CategoryID"] != null) query.CategoryID = this.CategoryID; if (ViewState["DateFilter"] != null) query.DateFilter = this.DateFilter; if (ViewState["FirstPageOnly"] != null) query.FirstPageOnly = this.FirstPageOnly; if (ViewState["GroupID"] != null) query.GroupID = this.GroupID; if (ViewState["IsAggregate"] != null) query.IsAggregate = this.IsAggregate; if (ViewState["LogicallyOrTags"] != null) query.LogicallyOrTags = this.LogicallyOrTags; if (ViewState["MaximumSpamScore"] != null) query.MaximumSpamScore = this.MaximumSpamScore; if (ViewState["MinimumSpamScore"] != null) query.MinimumSpamScore = this.MinimumSpamScore; if (ViewState["FilterByPostIDs"] != null) query.FilterByPostIDs = this.FilterByPostIDs; if (ViewState["PageIndex"] != null) query.PageIndex = this.PageIndex; if
using System;
using System.Collections.Generic;
using System.Text;
using CommunityServer.Components;
using System.Web.UI;
// CAB: Custom - Bug Fix for post list paging - derives from PostQuery now
// - Compare with changeset 229 for code differences
namespace CommunityServer.Controls
{
/// <summary>
/// Query options for accessing Post objects.
/// </summary>
public class PostQueryWithType : PostQuery
#region Public Properties
/// Gets or sets the index of the page of objects to display. This value is overridden when a PagerID is specified.
/// <value>The index of the page to display.</value>
public override int PageIndex
get
object val = ViewState["PageIndex"];
return val == null ? 0 : (int)val;
}
set
ViewState["PageIndex"] = value;
if (this.Pager != null)
this.Pager.PageIndex = value;
/// Gets or sets the number of objects to show on a single page.
/// <value>The size of the page.</value>
public override int PageSize
object val = ViewState["PageSize"];
return val == null ? 15 : (int)val;
set { ViewState["PageSize"] = value; }
/// Gets or sets the ID of the IPager control to use to control the current PageIndex.
/// <value>The pager ID.</value>
public override string PagerID
get { return ((string)ViewState["PagerID"]) ?? string.Empty; }
set { ViewState["PagerID"] = value; }
private IPager _pager = null;
/// Gets or sets the IPager control used to control the current PageIndex.
/// <value>The pager.</value>
public override IPager Pager
if (_pager == null && !string.IsNullOrEmpty(PagerID))
_pager = CSControlUtility.Instance().FindControl(this, PagerID) as IPager;
return _pager;
_pager = value;
PagerID = ((Control)_pager).ID;
/// Gets or sets the type of this query; the generic location/relationship from which data will be retrieved.
/// <value>The type of the query.</value>
public PostQueryType QueryType
object var = ViewState["QueryType"];
return var == null ? PostQueryType.Default : (PostQueryType)var;
set { ViewState["QueryType"] = value; }
#endregion
#region Apply Overrides method
/// Applies the query overrides to the underlying query.
/// <param name="query">The query.</param>
public virtual void ApplyQueryOverrides(PostQueryWithType query)
if (Pager != null)
this.PageIndex = Pager.PageIndex;
if (ViewState["CategoryID"] != null)
query.CategoryID = this.CategoryID;
if (ViewState["DateFilter"] != null)
query.DateFilter = this.DateFilter;
if (ViewState["FirstPageOnly"] != null)
query.FirstPageOnly = this.FirstPageOnly;
if (ViewState["GroupID"] != null)
query.GroupID = this.GroupID;
if (ViewState["IsAggregate"] != null)
query.IsAggregate = this.IsAggregate;
if (ViewState["LogicallyOrTags"] != null)
query.LogicallyOrTags = this.LogicallyOrTags;
if (ViewState["MaximumSpamScore"] != null)
query.MaximumSpamScore = this.MaximumSpamScore;
if (ViewState["MinimumSpamScore"] != null)
query.MinimumSpamScore = this.MinimumSpamScore;
if (ViewState["FilterByPostIDs"] != null)
query.FilterByPostIDs = this.FilterByPostIDs;
if (ViewState["PageIndex"] != null)
query.PageIndex = this.PageIndex;
if