datapager inside listview doesnt refresh

i have an asp.net listview with a datapager inside it and both inside an updatepanel. and i have some radiobottuns and checkboxlists for filtering the listview’s database.
every filter make an ajax request to rebind the list view. everything works well but when i use checkboxlist to filter the datasource i got some problems.
assum i am at page 5 and then i click a filter to have some new data. i expect to have new listview with a datapager that start from page number1 but i have a new listview with a new datapager that work great but star at page 5. how can i refresh data pager?
here is my code:

                                <LayoutTemplate>
                                    <div class="RadListView RadListViewFloated RadListView_Default">


                                        <div class="rlvFloated">
                                            <div class="container-fluid" style="text-align:right;margin-right:15px;">
                                                <div class="row">
                                                    <div class="col-sm-12 nopadding">
                                                        <div class="div_pager_container">
                                                            <asp:DataPager ID="DataPager1" runat="server" PageSize="9" PagedControlID="RadListView1">
                                                                <Fields>
                                                                    <asp:NextPreviousPagerField RenderNonBreakingSpacesBetweenControls="true" ShowFirstPageButton="true" ShowPreviousPageButton="true" ShowLastPageButton="false" ShowNextPageButton="false" PreviousPageText="<" FirstPageText="&laquo;" ButtonType="Link" ButtonCssClass="next_style" />
                                                                    <asp:NumericPagerField RenderNonBreakingSpacesBetweenControls="true" CurrentPageLabelCssClass="current_style" NumericButtonCssClass="num_style" ButtonType="Link" ButtonCount="8" NextPageText="" PreviousPageText="" />
                                                                    <asp:NextPreviousPagerField ShowLastPageButton="true" NextPageText=">" RenderNonBreakingSpacesBetweenControls="false" LastPageText="&raquo;" ShowPreviousPageButton="False" ButtonType="Link" ButtonCssClass="pre_style" />
                                                                </Fields>
                                                            </asp:DataPager>
                                                        </div>
                                                    </div>
                                                </div>
                                                    <div class="row">
                                            <div id="itemPlaceholder" runat="server">
                                            </div>

                                                        </div>
                                                </div>

                                        </div>

                                    </div>
                                </LayoutTemplate>
                                <ItemTemplate>

                                    <div id="tab">
                                             <div class="rlvI col-md-4  lv_items nopadding active" style="float:right;"  oncontextmenu="return false">

                                        <table class="tbl_product">

                                            <tr>
                                                <td>
                                                    <asp:ImageButton ID="Image2" CommandName="Select" CssClass="img-responsive img_product" runat="server" ImageUrl='<%# Eval("product_img") %>' AlternateText='<%# Eval("product_name") %>' OnClientClick="var originalTarget = document.forms[0].target; document.forms[0].target = '_blank'; setTimeout(function () { document.forms[0].target = originalTarget; }, 3000);"/>
                                                 </td>
                                            </tr>
                                             <tr>
                                                <td>
                                                    <asp:Image ID="brand_image" runat="server" />
                                                </td>
                                            </tr>
                                             <tr>
                                                <td>
                                                     <asp:Label ID="Label1" Font-Size="13px" Font-Bold="true" Font-Names="Klavik"  runat="server" Text='<%# Eval("product_name") %>' />
                                                </td>
                                            </tr>
                                             <tr>
                                                <td>
                                                     <asp:Label ID="Label2" CssClass="lbl_price_style_num" runat="server" Text='<%# Eval("product_price") %>' />
                                                    <asp:Label ID="Label3" CssClass="lbl_price_style" runat="server" Text="تومان" />
                                                </td>
                                            </tr>

                                        </table>
                                        </div>

                                             <div class="rlvI col-md-12 lv_items nopadding">

                                             <table class="tbl_product tbl_fullwidth list_type_body">

                                            <tr>
                                                <td style="width:30%;">
                                                    <span style="margin-left:20px;margin-right:7px;">
                                                        <asp:ImageButton ID="ImageButton1" CommandName="Select" CssClass="img_product" runat="server" ImageUrl='<%# Eval("product_img") %>' AlternateText='<%# Eval("product_name") %>' OnClientClick="var originalTarget = document.forms[0].target; document.forms[0].target = '_blank'; setTimeout(function () { document.forms[0].target = originalTarget; }, 3000);" />
                                                    </span>
                                                </td>
                                                <td style="width:70%;">

                                                    <table class="tbl_fullwidth">

                                                        <tr>
                                                            <td class="tbl_fullwidth">
                                                                 <asp:Label ID="Label7" Font-Bold="true" Font-Names="Klavik" runat="server" Text='<%# Eval("product_name") %>' />
                                                                <asp:Image ID="list_product_brand" runat="server" CssClass="img_product_logo leftfloat" />
                                                                 <hr />
                                                            </td>
                                                        </tr>
                                                        <tr>
                                                            <td class="tbl_fullwidth">
                                                                <asp:Label ID="Label4" CssClass="lbl_price_style" runat="server" Text="قیمت: " />
                                                                 <asp:Label ID="Label8"  CssClass="lbl_price_style_num" runat="server" Font-Names="Antipasto" Text='<%# Eval("product_price") %>' />
                                                                 <asp:Label ID="Label9" CssClass="lbl_price_style" runat="server" Text="تومان" />
                                                                <hr />
                                                            </td>
                                                        </tr>
                                                        <tr>
                                                            <td class="tbl_fullwidth">
                                                                <asp:Label ID="Label5" runat="server" Text="توضیحات:" />
                                                                <br />
                                                                <br />
                                                            </td>
                                                        </tr>
                                                        <tr>
                                                            <td class="tbl_fullwidth">
                                                                <asp:Label ID="Label6" runat="server" Text='<%# Eval("product_description") %>' />
                                                            </td>
                                                        </tr>

                                                    </table>

                                                </td>
                                            </tr>

                                        </table>

                                        </div>

                                    </div>










                                </ItemTemplate>


                                <EmptyDataTemplate>
                                    <div class="RadListView RadListView_Default">
                                        <div class="rlvEmpty" dir="rtl">
                                            <label>هیچ کالایی برای نمایش وجود ندارد</label>
                                            </div>
                                    </div>
                                </EmptyDataTemplate>



                            </asp:ListView>

and codebehind:

protected void RadListView1_PagePropertiesChanging(object sender, PagePropertiesChangingEventArgs e)
{
(RadListView1.FindControl(“DataPager1”) as DataPager).SetPageProperties(e.StartRowIndex, e.MaximumRows,false);

    filterdatabinding(); 
}


Source: ajax

Leave a Reply