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>