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

Upgrade problem - Unable to cast object of type 'Telerik.Web.UI.ElasticButton' to type 'System.Web.UI.WebControls.LinkButton'

2 Answers 620 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Skúli
Top achievements
Rank 1
Skúli asked on 09 May 2015, 10:42 PM

Hello,

After I updated to 2015 q1 I get following error

Upgrade problem - Unable to cast object of type 'Telerik.Web.UI.ElasticButton' to type 'System.Web.UI.WebControls.LinkButton'

This happens in ItemCreated. I was using following code to hide insertitem when I used insertbutton to open a Radwindow.

 

protected void ClassesOverviewGrid_ItemCreated(object sender, Telerik.Web.UI.GridItemEventArgs e)
    {
        if (e.Item is GridEditableItem && e.Item.IsInEditMode)
        {
            if (e.Item.OwnerTableView.IsItemInserted)
            {
                GridEditableItem item = e.Item as GridEditableItem;

                LinkButton updateButton = (LinkButton)item.FindControl("PerformInsertButton");

                ((GridTableRow)updateButton.Parent.Parent).Style.Value += "display:none";

            }
        }

}

 

If I change to 

LinkButton updateButton = (LinkButton)item.FindControl("PerformInsertButton");

((GridTableRow)updateButton.Parent.Parent).Style.Value += "display:none";

then I get the error in second line:

 

Additional information: Unable to cast object of type 'EditFormTableCell' to type 'Telerik.Web.UI.GridTableRow'.

 

Do you know how I can fix this?

2 Answers, 1 is accepted

Sort by
0
Pavlina
Telerik team
answered on 11 May 2015, 07:29 PM
Hello,

You have already received a reply to the support ticket opened on the same matter by my colleague Maria. However I am pasting her answer here in case someone else encounter the same problem

I suppose that you are using the RadGrid control in LIghtwight render mode. In this mode the update buttons are actually ElasticButton type and not LinkButton's. Therefore please cast the button to the correct ElasticButton type and see how it goes.
For example:
ElasticButton updateButton = (ElasticButton)item.FindControl("PerformInsertButton");
 

Note that the type comes form the Telerik.Web.UI namespace which should be referenced on the page.


Regards,
Pavlina
Telerik
 

See What's Next in App Development. Register for TelerikNEXT.

 
0
Guillermo José
Top achievements
Rank 1
answered on 12 Apr 2017, 09:11 PM

Hello Pavlina,

I got the same error regarding the casting of a telerik object. I have removed the telerik compresion but my page is using a dinamic layer to create the control in the page, so i will be removing the telerik compresion for all the clases in the control layer. However, can you provide more information regarding the error. Please see below the details:

Impossible d'effectuer un cast d'un objet de type 'Telerik.Web.UI.CompressedPageState' en type 'System.Collections.IDictionary'.

Informations sur l'erreur: Type: InvalidCastException Message: Impossible d'effectuer un cast d'un objet de type 'Telerik.Web.UI.CompressedPageState' en type 'System.Collections.IDictionary'. Trace de la pile: à System.Web.UI.Page.RegisterRequiresControlState(Control control) à Telerik.Web.UI.RadComboBox.OnInit(EventArgs e) à System.Web.UI.Control.InitRecursive(Control namingContainer) à System.Web.UI.Control.AddedControl(Control control, Int32 index) à System.Web.UI.ControlCollection.Add(Control child) à Telerik.Web.UI.GridPagerButtonBuilder.CreatePageSizeDropDown(Panel container) à Telerik.Web.UI.GridPagerButtonBuilder.CreatePageSize(Panel container) à Telerik.Web.UI.GridPagerItem.InitializePagerItem(GridColumn[] columns) à Telerik.Web.UI.GridPagerItem.SetupItem(Boolean dataBind, Object dataItem, GridColumn[] columns, ControlCollection rows) à Telerik.Web.UI.GridTableView.CreateTopPagerItem(Boolean useDataSource, GridColumn[] copiedColumnSet, Boolean isPagingEnabled, GridTHead thead) à Telerik.Web.UI.GridTableView.CreateControlHierarchy(Boolean useDataSource) à Telerik.Web.UI.GridTableView.CreateChildControls(IEnumerable dataSource, Boolean useDataSource) à System.Web.UI.WebControls.CompositeDataBoundControl.PerformDataBinding(IEnumerable data) à System.Web.UI.WebControls.DataBoundControl.OnDataSourceViewSelectCallback(IEnumerable data) à System.Web.UI.DataSourceView.Select(DataSourceSelectArguments arguments, DataSourceViewSelectCallback callback) à System.Web.UI.WebControls.DataBoundControl.PerformSelect() à Telerik.Web.UI.GridTableView.PerformSelect() à System.Web.UI.WebControls.BaseDataBoundControl.DataBind() à Telerik.Web.UI.GridTableView.DataBind() à Telerik.Web.UI.RadGrid.DataBind() à Telerik.Web.UI.RadGrid.AutoDataBind(GridRebindReason rebindReason) à Telerik.Web.UI.RadGrid.OnLoad(EventArgs e) à Env.MYAPPLICATION.Web.Controles.FormulaireGrilleGenerique`1.OnLoad(EventArgs e) dans e:MYAPPLICATION\Env.MYAPPLICATION.Web.Controles\FormulaireGrilleGenerique.cs:ligne 90 à System.Web.UI.Control.LoadRecursive() à System.Web.UI.Control.LoadRecursive() à System.Web.UI.Control.LoadRecursive() à System.Web.UI.Control.LoadRecursive() à System.Web.UI.Control.LoadRecursive() à System.Web.UI.Control.LoadRecursive() à System.Web.UI.Control.LoadRecursive() à System.Web.UI.Control.LoadRecursive() à System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) 

Line 90: MYAPPLICATION\Env.MYAPPLICATION.Web.Controles\FormulaireGrilleGenerique.cs:ligne 90:

protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);      

        }

 

Tags
Grid
Asked by
Skúli
Top achievements
Rank 1
Answers by
Pavlina
Telerik team
Guillermo José
Top achievements
Rank 1
Share this question
or