Pagination previous and next button not working

5 posts, 0 answers
  1. Simar
    Simar avatar
    2 posts
    Member since:
    Sep 2012

    Posted 10 Jul 2014 Link to this post

    Hi , 

    I am using grid to display my resultset. The problem is that my nextpage button only works once , it only move from 1 to 2 and then if i press next button it is not going to  page3. But if i individually press 3 it show right results. 
    Also , after pressing last page button , if i press previous page button it goes to page 1, this is happening even i am on any page after page 2.

    I think my previous and next page behaving like first and last page thats why it only work for page 1 and 2.

    <telerik:RadGrid ID="RadGrid1" runat="server" AllowPaging="True" CellSpacing="0"
                    GridLines="None" OnNeedDataSource="RadGrid1_NeedDataSource1" 
                     BorderStyle="None" OnItemDataBound="RadGrid1_ItemDataBound"    >
                     <PagerStyle Mode="NextPrevAndNumeric"   />
                    <MasterTableView AutoGenerateColumns="true">
                      
                    </MasterTableView>
                </telerik:RadGrid>

    codebehind:

      protected void RadGrid1_NeedDataSource1(object source, Telerik.Web.UI.GridNeedDataSourceEventArgs e)
            {
                                           RadGrid1.DataSource = list;
             }
             
            protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)
            {
                if (e.Item is  GridPagerItem)
                {
                    Label lblPageSize = (Label)e.Item.FindControl("ChangePageSizeLabel");
                    lblPageSize.Text = Sitecore.Globalization.Translate.Text("Results per page");

                        RadGrid1.PagerStyle.PagerTextFormat = "{4} {5} items in {1} pages";
                 }
            }
    Any help or advise.

    thanks in Advance.




  2. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 10 Jul 2014 in reply to Simar Link to this post

    Hi Simar,

    This not an expected behavior. Please try the below sample code snippet and see if you are able to replicate the issue. Can you give more details about the version of Telerik controls you are using and is this issue there in all browsers?

    ASPX:
    <telerik:RadAjaxPanel ID="rajaxpanelGrid" runat="server">
        <telerik:RadGrid ID="RadGrid1" runat="server" AllowPaging="true" PageSize="3" OnNeedDataSource="RadGrid1_NeedDataSource" OnItemDataBound="RadGrid1_ItemDataBound">
          <PagerStyle Mode="NextPrevAndNumeric" />      
        </telerik:RadGrid>
    </telerik:RadAjaxPanel>

    C#:
    protected void RadGrid1_NeedDataSource(object sender, GridNeedDataSourceEventArgs e)
    {
        dynamic data = new[] {
    new { ID = 1, Name = "Name1", Number=123},
    new { ID = 2, Name = "Name2", Number=234},
    new { ID = 3, Name = "Name3", Number=234},
    new { ID = 4, Name = "Name1", Number=456},
    new { ID = 5, Name = "Name3", Number=567},
    new { ID = 6, Name = "Name4", Number=567},
    new { ID = 7, Name = "Name7", Number=789},
    new { ID = 8, Name = "Name2", Number=896},
    new { ID = 5, Name = "Name3", Number=567},
    new { ID = 6, Name = "Name4", Number=567},
    new { ID = 7, Name = "Name7", Number=789},
    new { ID = 8, Name = "Name2", Number=896},
    new { ID = 9, Name = "Name1", Number=741}
    };
        RadGrid1.DataSource = data;      
    }
    protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)
    {
        if (e.Item is GridPagerItem)
        {
            Label lblPageSize = (Label)e.Item.FindControl("ChangePageSizeLabel");
            lblPageSize.Text = "Results per page";
            RadGrid1.PagerStyle.PagerTextFormat = "{4} {5} items in {1} pages";
        }
    }

    Thanks,
    Princy
  3. Simar
    Simar avatar
    2 posts
    Member since:
    Sep 2012

    Posted 10 Jul 2014 in reply to Princy Link to this post

    Hi Princy,

    I am able to replicate an issue with your code and it is in all browsers.
    The version of telerik control:
    UI for ASP.NET AJAX
    Your current available version:
    2014.2 618 (Jun 18, 2014)
  4. Eyup
    Admin
    Eyup avatar
    3823 posts

    Posted 15 Jul 2014 Link to this post

    Hi Simar,

    This behavior is strange, indeed. I have created a sample RadGrid web site using the provided code snippets to test the described behavior. On my side the paging functionality of the grid works as expected. Can you please run the attached application and let me know about the result?

    Regards,
    Eyup
    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.

     
  5. DogBizPro
    DogBizPro avatar
    158 posts
    Member since:
    Aug 2013

    Posted 06 Oct 2017 in reply to Eyup Link to this post

    I am having the same issue. It only pages the first time. Please help!
Back to Top