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

Unable to cast object of type 'ASP.masterpage_master' to type 'Telerik.Web.UI.GridTableView'.

5 Answers 262 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Chris Marisic
Top achievements
Rank 1
Chris Marisic asked on 10 Sep 2009, 04:51 PM
Using 3.5 controls - Have Telerik project set to use the 3.5 binary inside my solution structure.

I have a web page with a gridview control with paging enabled. The data is coming from a sql datasource (I also tried changing it to use a List<> with the OnNeedDataSource event.

I can view the grid fine and page back and forth between the numeric pages however when I change the PageSize drop down I get this error message.

Unable to cast object of type 'ASP.masterpage_master' to type 'Telerik.Web.UI.GridTableView'.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.InvalidCastException: Unable to cast object of type 'ASP.masterpage_master' to type 'Telerik.Web.UI.GridTableView'.

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:

[InvalidCastException: Unable to cast object of type 'ASP.masterpage_master' to type 'Telerik.Web.UI.GridTableView'.]
   Telerik.Web.UI.RadGrid.RaisePostBackEvent(String eventArgument) +1719
   System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13
   System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +175
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1565

I put the Telerik.Web.UI.DLL into reflector and inspected the  raisepostbackevent method for the radgrid I'm only seeing 2 places where it directly casts it to a GridTableView

    if (eventArgument.IndexOf("FireCommand") != -1) 
    { 
        GridGroupByExpression expression2; 
        GridGroupByExpression expression3; 
        string id = eventArgument.Split(new char[] { ';' })[0].Split(new char[] { ':' })[1]; 
        GridTableView tableView = (GridTableView) this.Page.FindControl(id); 
 ...
    if (eventArgument.IndexOf("ReorderColumns") != -1) 
    { 
        GridTableView view = (GridTableView) this.Page.FindControl(eventArgument.Split(new char[] { ',' })[1]); 

Is there any chance that eventArgument.Split is returning something like "this" that it would pick up the masterpage reference somehow?

Or does anyone have any idea what could be causing this error?


5 Answers, 1 is accepted

Sort by
0
Chris Marisic
Top achievements
Rank 1
answered on 10 Sep 2009, 05:40 PM
I was looking at my post data that was occurring and this is what happens when I change the value of the drop down

__EVENTARGUMENT FireCommand:_ctl0:cphMainContent:RadGrid1:_ctl0;PageSize;20

I believe _ctl10 would be the masterpage, is it doing FindControl("_ctl10")?

I created a UnitTest with

string eventArgument = "FireCommand:_ctl0:cphMainContent:RadGrid1:_ctl0;PageSize;20"
string id = eventArgument.Split(new char[] { ';' })[0].Split(new char[] { ':' })[1];  

And ID is in fact ctl10
0
Chris Marisic
Top achievements
Rank 1
answered on 10 Sep 2009, 06:29 PM
On further inspection I created a blank Telerik Web app project with my grid and inspected the post events for it

__EVENTARGUMENT FireCommand:RadGrid1$ctl00;PageSize;20

This submits what would be expected. It appears to only be an issue when involving a master page.
0
Accepted
Rosen
Telerik team
answered on 11 Sep 2009, 06:21 AM
Hello Chris,

Can you please verify that you do not have xhtmlConformance attribute set in your web config? You may check this blog post by ScottGu for more details on the subject.

Best wishes,
Rosen
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Chris Marisic
Top achievements
Rank 1
answered on 11 Sep 2009, 12:29 PM
That tag was buried inside the web.config I changed it to

<xhtmlConformance mode="Transitional" /> 

and this issue went away. Thanks!
0
smith spd
Top achievements
Rank 1
answered on 12 Jul 2010, 09:22 PM
Was very helpful.....

Thank u soooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo^n much
Tags
General Discussions
Asked by
Chris Marisic
Top achievements
Rank 1
Answers by
Chris Marisic
Top achievements
Rank 1
Rosen
Telerik team
smith spd
Top achievements
Rank 1
Share this question
or