GridPageChangedEventArgs Exception!

5 posts, 0 answers
  1. Edward Sudit
    Edward Sudit avatar
    30 posts
    Member since:
    Aug 2012

    Posted 19 Nov 2015 Link to this post

    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

  2. Konstantin Dikov
    Admin
    Konstantin Dikov avatar
    2466 posts

    Posted 24 Nov 2015 Link to this post

    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
  3. Edward Sudit
    Edward Sudit avatar
    30 posts
    Member since:
    Aug 2012

    Posted 24 Nov 2015 in reply to Konstantin Dikov Link to this post

    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

  4. Konstantin Dikov
    Admin
    Konstantin Dikov avatar
    2466 posts

    Posted 24 Nov 2015 Link to this post

    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
  5. Edward Sudit
    Edward Sudit avatar
    30 posts
    Member since:
    Aug 2012

    Posted 24 Nov 2015 in reply to Edward Sudit Link to this post

    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

Back to Top