This is a migrated thread and some comments may be shown as answers.
Pagination previous and next button not working
4 Answers 50 Views
This is a migrated thread and some comments may be shown as answers.
Simar
Top achievements
Rank 1
Simar asked on 10 Jul 2014, 02:44 PM
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.




4 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 1
answered on 11 Jul 2014, 04:28 AM
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
0
Simar
Top achievements
Rank 1
answered on 11 Jul 2014, 04:51 AM
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)
0
Eyup
Telerik team
answered on 15 Jul 2014, 09:09 AM
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.

 
0
DogBizPro
Top achievements
Rank 1
answered on 06 Oct 2017, 05:15 PM
I am having the same issue. It only pages the first time. Please help!
Tags
Grid
Asked by
Simar
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 1
Simar
Top achievements
Rank 1
Eyup
Telerik team
DogBizPro
Top achievements
Rank 1
Share this question
or