This is a migrated thread and some comments may be shown as answers.

RadGrid page size change event fired twice

9 Answers 672 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Sups
Top achievements
Rank 1
Sups asked on 18 Feb 2009, 12:43 PM

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

9 Answers, 1 is accepted

Sort by
0
Yavor
Telerik team
answered on 20 Feb 2009, 02:02 PM
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.
0
Sups
Top achievements
Rank 1
answered on 24 Feb 2009, 11:33 AM
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
0
Yavor
Telerik team
answered on 26 Feb 2009, 12:44 PM
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.
0
abhay
Top achievements
Rank 1
answered on 20 Dec 2011, 07:26 AM
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
0
Pavlina
Telerik team
answered on 20 Dec 2011, 09:51 AM
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
0
abhay
Top achievements
Rank 1
answered on 20 Dec 2011, 10:30 AM
Thanks... now it is calling only once... but in my ItemCommand event it is firing twice... any suggestions?
0
Pavlina
Telerik team
answered on 20 Dec 2011, 04:29 PM
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
0
Swathi
Top achievements
Rank 1
answered on 21 Jan 2015, 10:18 AM
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.                                                                                                                                                                                                                                                





















0
Pavlina
Telerik team
answered on 23 Jan 2015, 09:33 PM
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.

 
Tags
Grid
Asked by
Sups
Top achievements
Rank 1
Answers by
Yavor
Telerik team
Sups
Top achievements
Rank 1
abhay
Top achievements
Rank 1
Pavlina
Telerik team
Swathi
Top achievements
Rank 1
Share this question
or