RadGrid page size change event fired twice

10 posts, 0 answers
  1. Sups
    Sups avatar
    24 posts
    Member since:
    Jul 2007

    Posted 18 Feb 2009 Link to this post

    Hello,

    I face a issue with pagesize change event of RadGrid. This event is called two times when a user clicks on "Change" link.
    I have set  AllowPaging="True", AllowCustomPaging="True", PagerStyle-Mode="NextPrevNumericAndAdvanced"  
    properties of Radgrid related to paging.

    In code I have following events...

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load      
        
    If Not Page.IsPostBack Then        
            BindGrid()
        
    End If
    End Sub 

    Private Sub BindGrid()  
        '''' grid binding code here using datasource as datatable
        dt = .....
        If dt.Rows.Count > 0 Then
            rGridSubscriptions.VirtualItemCount = dt.Rows(0).Item("total_rows")
        Else
            rGridSubscriptions.VirtualItemCount = 0
        End If
    End Sub

    Private Sub
    rGridSubscriptions_PageSizeChanged(ByVal source As Object, ByVal e As Telerik.Web.UI.GridPageSizeChangedEventArgs) Handles rGridSubscriptions.PageSizeChanged    
        ViewState(
    "maxRows") = e.NewPageSize
        BindGrid()
    End Sub

    This PageSizeChanged is called twice when "Change" link is clicked and hence Bindgrid is called twice. I am using Telerik's Q2 2008 version.
    Please if anyone can solve this issue it would be of greate help.

    Thanks in advance
    Sups

  2. Yavor
    Admin
    Yavor avatar
    11 posts

    Posted 20 Feb 2009 Link to this post

    Hi Sups,

    Can you please try populating the control with data by using the NeedDataSource event handler, and see if this eliminates the issue.

    Regards,
    Yavor
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Sups
    Sups avatar
    24 posts
    Member since:
    Jul 2007

    Posted 24 Feb 2009 Link to this post

    Hello Yavor,

    I tried to bind the grid using NeedDataSource as suggested but this also didn't work. Here also when I try to debug, the debugger goes twice in the PageSizeChanged event.

    BindGrid, PageSizeChanged & NeedDataSource event are as follows:

    Private function BindGrid() as DataTable
        Dim dt as new DataTable
        dt = GetData()......

        return dt
    End Function

    Protected Sub rGridSubscriptions_PageSizeChanged(ByVal source As Object, ByVal e As Telerik.Web.UI.GridPageSizeChangedEventArgs) Handles rGridSubscriptions.PageSizeChanged
        ViewState("maxRows") = e.NewPageSize
    End Sub

    Protected Sub rGridSubscriptions_NeedDataSource(ByVal source As Object, ByVal e As GridNeedDataSourceEventArgs) Handles rGridSubscriptions.NeedDataSource
            rGridSubscriptions.DataSource = BindGrid()
    End Sub

    Is there any other solution for this issue?

    Thanks
    Sups
  5. Yavor
    Admin
    Yavor avatar
    11 posts

    Posted 26 Feb 2009 Link to this post

    Hi Sups,

    If the control is properly populated with data, you can open a formal support ticket, and send us the problematic code, in the form of a small working project, for additional testing.

    Greetings,
    Yavor
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  6. abhay
    abhay avatar
    6 posts
    Member since:
    Oct 2006

    Posted 20 Dec 2011 Link to this post

    Hello,

    I'm also facing the same problem... The PageSizeChanged event is being fired twice. Is it solved yet? Or is that fine the event being fired twice?

    Regards,
    Abhay
  7. Pavlina
    Admin
    Pavlina avatar
    6084 posts

    Posted 20 Dec 2011 Link to this post

    Hello Abhay,

    PageSizeChanged event is fired twice, because the first time its raised from the MasterTableView for the grid (when setting it client side) and it bubbles up and the second time it is raised from the grid itself.
    The issue is logged and we will try fixing it shortly. Currently, to workaround the problem, you can disable paging for the grid and enable it for the MasterTableView only.
    <telerik:RadGrid ID="RadGrid1" runat="server" OnPageSizeChanged="RadGrid1_PageSizeChanged"
        DataSourceID="SqlDataSource1" PageSize="10">
        <MasterTableView AllowPaging="true" TableLayout="Fixed">

    Kind regards,
    Pavlina
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
  8. abhay
    abhay avatar
    6 posts
    Member since:
    Oct 2006

    Posted 20 Dec 2011 Link to this post

    Thanks... now it is calling only once... but in my ItemCommand event it is firing twice... any suggestions?
  9. Pavlina
    Admin
    Pavlina avatar
    6084 posts

    Posted 20 Dec 2011 Link to this post

    Hello Abhay,

    I tried to reproduce the described issue, but to no avail. I am sending you a simple example that is working as expected. Check it out and let me know what differs in your case.

    All the best,
    Pavlina
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
  10. Swathi
    Swathi avatar
    1 posts
    Member since:
    Jan 2015

    Posted 21 Jan 2015 in reply to Pavlina Link to this post

    Hii..
     i have same kind of issue. please let me know where am going wrong.

      am using RadGrid in my application, showing totals too in the footer( calculating in itemdatabound event). Issue is that, when am exporting grid to excel format, mastetableview_databinding() event is firing twice. and eventually radgrid1_itemCreated() and radgrid1_itemdatabound() events also firing twice. because of this, incorrect totals are being displayed in excel sheet.

    ex: if total is 100, it is showing 200(exactly double).

    importantly, exporting to word and pdf works well without any issues(with same code).

    code:
     protected void MasterTableView_DataBinding(object sender, EventArgs e)
            {

                foreach (GridColumn column in rgReport.MasterTableView.Columns)
                {
                    GridBoundColumn columns = rgReport.MasterTableView.Columns.FindByUniqueName(column.UniqueName) as GridBoundColumn;
                    if (column.UniqueName.ToLower() != "projectname")
                    {
                        columns.FooterStyle.CssClass = "footerpadding";
                        columns.FooterStyle.HorizontalAlign = HorizontalAlign.Right;
                    }
                    else
                    {
                        columns.FooterStyle.CssClass = "footerpaddingleft";
                        columns.FooterStyle.HorizontalAlign = HorizontalAlign.Left;
                    }
                }
            }

    please try to say, why it is getting rebinded.


    Thanks.                                                                                                                                                                                                                                                





















  11. Pavlina
    Admin
    Pavlina avatar
    6084 posts

    Posted 23 Jan 2015 Link to this post

    Hello,

    Unfortunately, this isn't enough information for us to help diagnose the problem and provide a possible solution. Send us the complete code, include the entire markup and code behind for the page containing the Grid and we will advice you further.

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

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