PagePropertiesChanging event not firing for DataPager bound to a ListView when there are 2 DataPagers shown

1.6k views Asked by At

I have a page with two DataPagers, one above and one below the ListView they control. All the events fire on the first DataPager, however any subsequent DataPagers do not increment the page on the first page (they do on any other page).

<asp:DataPager runat="server" ID="uxTopPager" PagedControlID="uxFundList" PageSize="10" OnPreRender="PagerPreRender">
<Fields>
<asp:NextPreviousPagerField ButtonType="Link" ButtonCssClass="NextPrevious" ShowFirstPageButton="False" ShowLastPageButton="False" />
</Fields>
</asp:DataPager>
<table>
<th><!-- Table Headers --></th>
<asp:ListView runat="server" ID="ListView1" OnItemDataBound="FundListItemDataBound" OnPagePropertiesChanging="FundList_PagePropertiesChanging">
<ItemTemplate>
<tr><!-- Table Data--></tr>
</ItemTemplate>
</asp:ListView>
<asp:DataPager runat="server" ID="uxBottomPager" PagedControlID="uxFundList" PageSize="10"  OnPreRender="PagerPreRender">
<Fields>
<asp:NextPreviousPagerField ButtonType="Link" ButtonCssClass="NextPrevious" ShowFirstPageButton="False" ShowLastPageButton="False" />
</Fields>
</asp:DataPager>

Each Pager should fire the following events:

protected void PagerPreRender(object sender, EventArgs e)
    {
    uxFundList.DataBind();
    }
    protected void FundList_PagePropertiesChanging(object sender, PagePropertiesChangingEventArgs e)
    {
    uxFundList.DataBind();
    uxTopPager.SetPageProperties(((e.StartRowIndex- 1) * PageSize), uxTopPager.PageSize, false);
    uxBottomPager.SetPageProperties(((e.StartRowIndex- 1) * PageSize), uxBottomPager.PageSize, false);
    }

However the bottom pager (uxBottomPager) only fires PagerPreRender() and therefore doesn't increment the current page.

I cannot use the query string to control the pages as I have a large number of variables which would render the query string unusable.

Any help would be greatly appreciated.

1

There are 1 answers

0
Munawir On

This worked for me

protected void FundList_PagePropertiesChanging(object sender, PagePropertiesChangingEventArgs e)
{
    uxTopPager.SetPageProperties(e.StartRowIndex, e.MaximumRows, false);
    uxBottomPager.SetPageProperties(e.StartRowIndex, e.MaximumRows, false);
    BindListView();    //Function where datas are binded to listview
}