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

GridPageChangedEventArgs Exception!

4 Answers 97 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Edward Sudit
Top achievements
Rank 1
Edward Sudit asked on 20 Nov 2015, 01:53 AM

We are currently using version 2015.2.826 of Telerik controls.  We are getting intermittent exceptions from one of our pages where we have codebehind for handling the grid events.  The error we are getting is:

Unable to cast object of type 'System.EventArgs' to type 'Telerik.Web.UI.GridPageChangedEventArgs'

We have searched for any other customers with this problem, but are not able to find anything.  We definitely need your help on this production problem.

Thank you,

Ed Sudit

4 Answers, 1 is accepted

Sort by
0
Konstantin Dikov
Telerik team
answered on 24 Nov 2015, 08:31 AM
Hello Ed,

As the error states, you are trying to cast "System.EvetArgs" type to "Telerik.Web.UI.GridPageChangedEventArgs", so please examine your code-behind and see if the event parameters that you are using in the event handlers are of correct type and if you are not trying to cast "System.EvetArgs" type to "Telerik.Web.UI.GridPageChangedEventArgs".

If further assistance is needed, please provide the code-behind of your RadGrid, so we can take a look at your implementation.


Regards,
Konstantin Dikov
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Edward Sudit
Top achievements
Rank 1
answered on 24 Nov 2015, 02:43 PM

Hello Konstantin,

 We are not doing an implicit cast.  The code is very straight forward where we are handling an event from the RadGrid in our codebehind.  Here is the partial code that seems to be throwing this exception intermittently:

ASPX:

<Telerik:RadGrid ID="grdReceivedEmails" runat="server" AutoGenerateColumns="false"
AllowPaging="true" AllowSorting="true" OnSortCommand="grdReceivedEmails_SortCommand"
OnPageSizeChanged="grdReceivedEmails_PageSizeChanged"
OnPageIndexChanged="grdReceivedEmails_PageIndexChanged"
OnSelectedIndexChanged="grdReceivedEmails_PageIndexChanged"
CellPadding="0" CellSpacing="0" AllowMultiRowSelection="false">

VB Code:

Protected Sub grdReceivedEmails_PageIndexChanged(ByVal sender As Object, ByVal e As Telerik.Web.UI.GridPageChangedEventArgs)
grdReceivedEmails.CurrentPageIndex = e.NewPageIndex
BindReceivedEmails()
End Sub

0
Konstantin Dikov
Telerik team
answered on 24 Nov 2015, 03:02 PM
Hi Edward,

You have attached the same event handler, as for the OnPageIndexChanged event, to the OnSelectedIndexChanged event, which is the cause of the problem. Please set different event handler for the OnSelectedIndexChanged event with EventArgs as a second argument:
Protected Sub RadGrid1_SelectedIndexChanged(sender As Object, e As EventArgs)
....
End Sub

 
Best Regards,
Konstantin Dikov
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Edward Sudit
Top achievements
Rank 1
answered on 24 Nov 2015, 03:15 PM

Hello again,

 Please disregard my previous post.  After pasting the code snippet, I realized what was being done incorrectly.  The OnSelectedIndexChanged event was being handled by a method that should not be handling it.  The implicit event argument was failing due to that.

Thank you for your reply, I've corrected the code now.

Ed Sudit

Tags
Grid
Asked by
Edward Sudit
Top achievements
Rank 1
Answers by
Konstantin Dikov
Telerik team
Edward Sudit
Top achievements
Rank 1
Share this question
or