RadDataPager not working on RadListView

3 posts, 0 answers
  1. Akinola
    Akinola avatar
    4 posts
    Member since:
    Mar 2012

    Posted 06 Jun 2012 Link to this post

    I have created a ListView that uses the Datapager, and have set them up as follows:

    <telerik:RadListView ID="RadListImageAsset" ItemPlaceholderID="ImageAssetContainer" runat="server" AllowPaging="true" Width="100%">

    </telerik:RadListView>
     
    and 

    <telerik:RadDataPager EnableEmbeddedSkins="false" ID="RadDataPager1"
                                                runat="server" PagedControlID="RadListImageAsset" PageSize="10">
                                                <Fields>
                                                    <telerik:RadDataPagerPageSizeField PageSizeText="Show Results: " PageSizeComboWidth="40" />
                                                    <telerik:RadDataPagerGoToPageField HorizontalPosition="RightFloat"  />
                                                    <telerik:RadDataPagerButtonField FieldType="Numeric" HorizontalPosition="RightFloat" />
                                                </Fields>
    </telerik:RadDataPager>

    However, my RadDataPagerButtonField and RadDataPagerGoToPageField do not work. Only the RadDataPagerPageSizeField works when I increase or decrease the number of dataitems to be displayed. Does anyone have any ideas about what may be causing the Datapager not to work when I want to view the next page using the GoTopageField and ButtonField.

    The datasource is being set each time, but the control isnt displaying the appropriate page.

    Please let me know if you need me to provide anything.

    Thanks,
    Akin
  2. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 07 Jun 2012 Link to this post

    Hi Akinola,

    Following is the sample code that I tried and which is worked as expected.

    ASPX:
    <telerik:RadListView ID="RadListView1" Width="97%" AllowPaging="True" runat="server" AllowSorting="true"  DataSourceID="SqlDataSource1" ItemPlaceholderID="ProductsHolder" DataKeyNames="ProductID">
       <LayoutTemplate>
          <fieldset style="width: 760px;" id="FieldSet1">
            <legend>Products</legend>
            <asp:Panel ID="ProductsHolder" runat="server" />
            <table cellpadding="0" cellspacing="0" width="100%;" style="clear: both;">
              <tr>
                <td>
                   <telerik:RadDataPager EnableEmbeddedSkins="false" ID="RadDataPager1" runat="server" PagedControlID="RadListView1" PageSize="10">
                     <Fields>
                       <telerik:RadDataPagerPageSizeField PageSizeText="Show Results: " PageSizeComboWidth="40" />
                       <telerik:RadDataPagerGoToPageField HorizontalPosition="RightFloat" />
                       <telerik:RadDataPagerButtonField FieldType="Numeric" HorizontalPosition="RightFloat" />
                     </Fields>
                  </telerik:RadDataPager>
                </td>
              </tr>
            </table>
          </fieldset>
       </LayoutTemplate>
       <ItemTemplate>
         <div style="float: left;">
           <table cellpadding="0" cellspacing="0" style="width: 230px; height: 100px">
             <tr>
               <td style="width: 20%;">
                 Name:
               </td>
               <td style="width: 80%; padding-left: 5px;">
                 <%# Eval("ProductName") %>
               </td>
             </tr>
             <tr>
               <td>
                 Quantity:
               </td>
               <td style="width: 80%; padding-left: 5px;">
                 <%# Eval("QuantityPerUnit") %>
               </td>
             </tr>
             <tr>
               <td>
                 Price:
               </td>
               <td style="width: 80%; padding-left: 5px;">
                 <%# DataBinder.Eval(Container.DataItem, "UnitPrice", "{0:C}") %>
               </td>
             </tr>
             <tr>
               <td>
                 Units:
               </td>
               <td style="width: 80%; padding-left: 5px;">
                 <%# Eval("UnitsInStock") %>
               </td>
             </tr>
             <tr>
               <td>
                 Available:
               </td>
               <td style="width: 80%; padding-left: 5px;">
                 <%# ((bool)DataBinder.Eval(Container.DataItem,"Discontinued") == false ? "Yes" : "No") %>
               </td>
             </tr>
             <tr>
               <td>
                 <hr />
               </td>
               <td>
                 <hr />
               </td>
             </tr>
           </table>
         </div>
       </ItemTemplate>
    </telerik:RadListView>
    <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString %>" SelectCommand="SELECT [ProductID], [ProductName], [QuantityPerUnit], [UnitPrice], [UnitsInStock], [Discontinued] FROM [Products]">
    </asp:SqlDataSource>

    Please take a look into this demo for more information. Please provide your entire code if it doesn't help.

    Thanks,
    Princy.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Meet
    Meet avatar
    1 posts
    Member since:
    Nov 2014

    Posted 05 Feb 2015 in reply to Akinola Link to this post

    Hi Akinola,
    You need to write server-side method for OnPageIndexChanged event of telerik listview.
    Add OnPageIndexChanged="radListViewPresentation_PageIndexChanged" in telerik listview on aspx page.
    Then add method as following:
    protected void radListView1_PageIndexChanged(object sender, RadListViewPageChangedEventArgs e)
    {
        radListView1.DataSource = <Your DataSource>
        radListView1.CurrentPageIndex = e.NewPageIndex;
        radListView1.DataBind();
    }
    Try this solution. It may work for you.

    Thanks,
    Meet
Back to Top