OnPageIndexChanged fire multiple times

2 posts, 0 answers
  1. Tonyz289
    Tonyz289  avatar
    50 posts
    Member since:
    Jun 2011

    Posted 26 Feb 2015 Link to this post

    I have a RadListView with a RadDataPager (see below). Every time a user hits "FirstPrev"
     button the OnPageIndexChanged  event fires three times.

    Why is this happening and how do I prevent it?

    <telerik:RadListView ID="RadListView1" runat="server" AllowPaging="True" ItemPlaceholderID="PlaceHolder1"
        Skin="listview_2" EnableEmbeddedSkins="false" OnItemDataBound="RadListView1_ItemDataBound" AllowCustomPaging="true"
        DataKeyNames="id,filenameextension,typeAbbr,title,fidTimeOfDay" OnNeedDataSource="RadListView1_NeedDataSource" OnPageIndexChanged="RadListView1_PageIndexChanged" OnPageSizeChanged="RadListView1_PageSizeChanged" >
        <LayoutTemplate>
            <div class="RadListView RadListViewFloated RadListView_Windows7">
                <telerik:RadDataPager ID="RadDataPager1" runat="server" PageSize="25" PagedControlID="RadListView1"
                    BorderWidth="0" OnFieldCreated="RadDataPager1_FieldCreated" CssClass="dataPagerClass">
                    <Fields>
                        <telerik:RadDataPagerButtonField FieldType="FirstPrev" />
                        <telerik:RadDataPagerButtonField FieldType="Numeric" PageButtonCount="5" />
                        <telerik:RadDataPagerButtonField FieldType="NextLast" />
                        <telerik:RadDataPagerPageSizeField PageSizeText="Page size: " />
                        <telerik:RadDataPagerGoToPageField CurrentPageText="Page: " TotalPageText="of" SubmitButtonText="Go"
                            TextBoxWidth="15" />
                        <telerik:RadDataPagerTemplatePageField>
                            <PagerTemplate>
                                <b>Total Number of Assets Found:
                                    <asp:Label runat="server" ID="TotalItemsLabel" Text="<%# Container.Owner.TotalRowCount%>" />
                                </b>
                            </PagerTemplate>
                        </telerik:RadDataPagerTemplatePageField>
                    </Fields>
                </telerik:RadDataPager>
                <asp:PlaceHolder ID="PlaceHolder1" runat="server" />
            </div>
        </LayoutTemplate>
        <ItemTemplate>
            <div style="float: left; width: 162px; height: 200px; background-color: White;">
                <asp:Panel ID="myThumb" runat="server" CssClass="myClass" Style="border: 0; white-space: normal; padding: 5px 4px 25px 2px; text-align: center; width: 160px; background-color: white; margin-left: 2px;">
                    <div style="width: 150px; height: 150px; margin-left: 2px;">
                        <asp:HyperLink ID="HyperLink1" runat="server">
                            <telerik:RadBinaryImage ID="RadBinaryImage1" runat="server" AutoAdjustImageControlSize="false"
                                CssClass="myClass" ImageUrl='<%# Eval("thumbUrl") %>' AlternateText="Click to view preview"
                                ToolTip="Click to view preview" />
                        </asp:HyperLink><br />
                    </div>
                    <asp:CheckBox ID="ChkImage" runat="server" Style="float: left; padding-top: 5px" /><small><asp:HyperLink
                        ID="lnkAsset1" runat="server" Visible="false" Style="float: left; padding-top: 5px; text-decoration: none; font-weight: normal; font-size: 7pt;">
                    </asp:HyperLink><asp:HyperLink ID="lnkAsset2" runat="server" Style="float: left; text-decoration: none; font-weight: normal; font-size: 7pt;">
                    </asp:HyperLink><asp:HyperLink ID="lnkAsset3" runat="server" Style="float: left; padding-left: 20px; text-decoration: none; font-weight: normal; font-size: 7pt;"></asp:HyperLink></small><br />
                    <asp:HiddenField ID="hiddenAssetId" Value='<%# Eval("id") %>' runat="server" />
                </asp:Panel>
            </div>
        </ItemTemplate>
        <EmptyDataTemplate>
            No Assets Found
        </EmptyDataTemplate>
    </telerik:RadListView>

  2. Konstantin Dikov
    Admin
    Konstantin Dikov avatar
    1800 posts

    Posted 03 Mar 2015 Link to this post

    Hello Tony,

    The behavior that you are describing is not expected, even with your current RadListView settings. Please note that once you enable the custom paging by setting the AllowCustomPaging property to true, you need to specify the VirtualItemCount as well to the control.

    Nevertheless, after test your your RadListView settings with dummy data, the OnPageIndexChanged event was firing only once on my end. Following is the example that I have tested:
    <telerik:RadListView ID="RadListView1" runat="server" AllowPaging="True" ItemPlaceholderID="PlaceHolder1"
        Skin="listview_2" EnableEmbeddedSkins="false" AllowCustomPaging="true"
        DataKeyNames="id" OnNeedDataSource="RadListView1_NeedDataSource" OnPageIndexChanged="RadListView1_PageIndexChanged" OnPageSizeChanged="RadListView1_PageSizeChanged">
        <LayoutTemplate>
            <div class="RadListView RadListViewFloated RadListView_Windows7">
                <telerik:RadDataPager ID="RadDataPager1" runat="server" PageSize="25" PagedControlID="RadListView1"
                    BorderWidth="0" OnFieldCreated="RadDataPager1_FieldCreated" CssClass="dataPagerClass">
                    <Fields>
                        <telerik:RadDataPagerButtonField FieldType="FirstPrev" />
                        <telerik:RadDataPagerButtonField FieldType="Numeric" PageButtonCount="5" />
                        <telerik:RadDataPagerButtonField FieldType="NextLast" />
                        <telerik:RadDataPagerPageSizeField PageSizeText="Page size: " />
                        <telerik:RadDataPagerGoToPageField CurrentPageText="Page: " TotalPageText="of" SubmitButtonText="Go"
                            TextBoxWidth="15" />
                        <telerik:RadDataPagerTemplatePageField>
                            <PagerTemplate>
                                <b>Total Number of Assets Found:
                            <asp:Label runat="server" ID="TotalItemsLabel" Text="<%# Container.Owner.TotalRowCount%>" />
                                </b>
                            </PagerTemplate>
                        </telerik:RadDataPagerTemplatePageField>
                    </Fields>
                </telerik:RadDataPager>
                <asp:PlaceHolder ID="PlaceHolder1" runat="server" />
            </div>
        </LayoutTemplate>
        <ItemTemplate>
            <div>
                <asp:Panel ID="myThumb" runat="server">
                    <div>
                        <asp:HyperLink ID="HyperLink1" runat="server">
                            <%# Eval("thumbUrl") %>
                        </asp:HyperLink><br />
                    </div>
                    <asp:CheckBox ID="ChkImage" runat="server" Style="float: left; padding-top: 5px" /><small><asp:HyperLink
                        ID="lnkAsset1" runat="server" Visible="false" Style="float: left; padding-top: 5px; text-decoration: none; font-weight: normal; font-size: 7pt;">
                    </asp:HyperLink><asp:HyperLink ID="lnkAsset2" runat="server" Style="float: left; text-decoration: none; font-weight: normal; font-size: 7pt;">
                    </asp:HyperLink><asp:HyperLink ID="lnkAsset3" runat="server" Style="float: left; padding-left: 20px; text-decoration: none;
                font-weight: normal; font-size: 7pt;"></asp:HyperLink></small><br />
                    <asp:HiddenField ID="hiddenAssetId" Value='<%# Eval("id") %>' runat="server" />
                </asp:Panel>
            </div>
        </ItemTemplate>
        <EmptyDataTemplate>
            No Assets Found
        </EmptyDataTemplate>
    </telerik:RadListView>

    And the code-behind:
    protected void Page_Load(object sender, EventArgs e)
    {
        RadListView1.VirtualItemCount = 50;
    }
    protected DataTable GetData()
    {
        DataTable table = new DataTable();
        table.Columns.Add("id", typeof(int));
        table.Columns.Add("thumbUrl", typeof(string));
        for (int i = 0; i < 50; i++)
        {
            table.Rows.Add(i, "thumbUrl" + i);
        }
     
        return table;
    }
     
    protected void RadListView1_NeedDataSource(object sender, RadListViewNeedDataSourceEventArgs e)
    {
        RadListView1.DataSource = GetData();
    }
     
    protected void RadListView1_PageIndexChanged(object sender, RadListViewPageChangedEventArgs e)
    {
         
    }
    protected void RadListView1_PageSizeChanged(object sender, RadListViewPageSizeChangedEventArgs e)
    {
     
    }
    protected void RadDataPager1_FieldCreated(object sender, RadDataPagerFieldCreatedEventArgs e)
    {
     
    }

    If you continue to experience the same issue, please take a look at the following help article and online demo or open a regular support ticket with a sample, runnable project attached:


    Kind Regards,
    Konstantin Dikov
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top