locked
Error on IPageableItemContainer RRS feed

  • Question

  • User-649410219 posted

    Hi all!

    I'm creating a control that implements IPageableItemContainer. It's simple, but it won't works as it could do. I put on page a DataPager with "Preview" and "Next". When I clin on "Next" the control show the "second" page, but the DataPage don't change itself ("Preview" still disabled and page number still "1").

    I put the members that implements IPageableItemContainer below.

    The _DataSource object is a PagedDataSource...

           #region " Implements IPageableItemContainer "
    
            /// <summary>
    /// Occurs when the data from the data source is made available to the control.
    /// </summary>
    public event EventHandler<PageEventArgs> TotalRowCountAvailable;

    /// <summary>
    /// Raises the TotalRowCountAvailable event.
    /// </summary>
    private void PagedDataList_TotalRowCountAvailable()
    {
    if (this.TotalRowCountAvailable != null)
    {
    PageEventArgs e = new PageEventArgs(this.StartRowIndex, this.MaximumRows, this.DataSourceCount);
    TotalRowCountAvailable(this, e);
    }
    }

    /// <summary>
    /// Sets the properties of a page of data.
    /// </summary>
    /// <param name="startRowIndex">The index of the first record on the page.</param>
    /// <param name="maximumRows">The maximum number of items on a single page.</param>
    /// <param name="databind">true to rebind the control after the properties are set; otherwise, false.</param>
    public void SetPageProperties(int startRowIndex, int maximumRows, bool databind)
    {
    this.PageSize = maximumRows;

    if (startRowIndex.CompareTo(0).Equals(1))
    {
    this._DataSource.CurrentPageIndex = (startRowIndex / maximumRows);
    }

    if (databind)
    {
    this.DataBind();
    }
    }

    /// <summary>
    /// Gets the maximum number of items to display on a single page of data.
    /// </summary>
    public int MaximumRows
    {
    get { return this.PageSize; }
    }

    /// <summary>
    /// Gets the index of the first record that is displayed on a page of data.
    /// </summary>
    public int StartRowIndex
    {
    get { return this._DataSource.FirstIndexInPage; }
    }

    #endregion</PageEventArgs>
      
    Friday, March 14, 2008 5:36 PM

All replies

  • User666765862 posted

    I would suspect it has something to do with how/where you're firing the OnTotalCountAvailable event.  Maybe you can post your databind function so that it can be seen how you're retrieving your data and firing that event.  You may also find this link helpful. It's a post that shows a step by step extension of the GridView control to work with the DataPager control.

     http://blogs.visoftinc.net/2008/03/19/default.aspx

    --D

    Monday, March 31, 2008 8:00 PM