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
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.
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
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.
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
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
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
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.
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.