Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6895105
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T06:51:58+00:00 2026-05-27T06:51:58+00:00

My RadGridView is throwing an System.InvalidCastException when there are GroupDescriptors applying a grouping to

  • 0

My RadGridView is throwing an System.InvalidCastException when there are GroupDescriptors applying a grouping to the items in the grid.

The exception is fairly unhelpful:

[A]DynamicDataType cannot be cast to [B]DynamicDataType. Type A originates from 'DynamicData, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null' in the context 'Default' in a byte array. Type B originates from 'DynamicData, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null' in the context 'Default' in a byte array.

  at Telerik.Windows.Data.FuncExtensions.<>c__DisplayClass1`2.<ToUntypedFunc>b__0(Object item)
   at Telerik.Windows.Data.QueryableCollectionViewGroup.FindLastLevelGroupByItem(Object item)
   at Telerik.Windows.Controls.GridView.GridViewDataControl.GetRowForItem(Object item, Boolean forceGroupExpand)
   at Telerik.Windows.Controls.GridView.GridViewDataControl.get_CurrentCell()
   at Telerik.Windows.Controls.GridView.GridViewDataControl.CanCellBecomeCurrent(GridViewCell cell)
   at Telerik.Windows.Controls.GridView.GridViewCell.OnMouseLeftButtonDown(MouseButtonEventArgs e)
   at System.Windows.Controls.Control.OnMouseLeftButtonDown(Control ctrl, EventArgs e)
   at MS.Internal.JoltHelper.FireEvent(IntPtr unmanagedObj, IntPtr unmanagedObjArgs, Int32 argsTypeIndex, Int32 actualArgsTypeIndex, String eventName)

When the groups are removed from the bar at the top of the grid, there is no problem and I can select the rows of the grid as per normal.

The problem perhaps appears to be related to a piece of code that I use to save the GridDescriptors between refreshes. The method takes in RefreshItemSourceLifetimeStage which is an enum.
This code is called before (AboutToRefresh) and after (FinishedRefresh) the ItemSource is changed with the appropriate argument.

    public void RefreshGrid(RefreshItemSourceLifetimeStage stage)
    {
        switch (stage)
        {
            case RefreshItemSourceLifetimeStage.AboutToRefresh:
                if (_grid.ItemsSource == null && !_grid.GroupDescriptors.Any())
                {
                    // default group descriptor that you get on initial page load
                    _savedGroupDescriptors.Add(new GroupDescriptor { Member = "_CallFactorSet.CreatedAt.Year", DisplayContent = "Year Created", SortDirection = ListSortDirection.Descending});
                }
                else
                {
                    _savedGroupDescriptors.Clear();
                    foreach (var igd in _grid.GroupDescriptors)
                    {
                        // we have to clone the objects into the _savedGroupDescriptors collection because otherwise they disappear when the itemsource is refreshed
                        if (igd is GroupDescriptor)
                        {
                            var gd = (GroupDescriptor) igd;
                            _savedGroupDescriptors.Add(new GroupDescriptor { Member = gd.Member, DisplayContent = gd.DisplayContent, SortDirection = gd.SortDirection });
                        }
                        else if (igd is ColumnGroupDescriptor)
                        {
                            var cgd = (ColumnGroupDescriptor) igd;
                            _savedGroupDescriptors.Add(new ColumnGroupDescriptor { Column = cgd.Column, DisplayContent = cgd.DisplayContent, SortDirection = cgd.SortDirection });
                        }
                    }
                }

                break;

            case RefreshItemSourceLifetimeStage.FinishedRefresh:
                _grid.GroupDescriptors.Clear();
                foreach(var groupDescriptor in _savedGroupDescriptors)
                {
                    _grid.GroupDescriptors.Add(groupDescriptor);
                }

                break;

            default:
                throw new ArgumentOutOfRangeException("stage");
        }
    }

Any ideas?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T06:51:59+00:00Added an answer on May 27, 2026 at 6:51 am

    Funnily enough updating to the latest version of the Telerik controls (2011 Q3 at the time of writing, up from 2011 Q2 SP1) seemed to fix the issue.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using Telerik Silverlight RadGridView to display instrument prices. There is a column
I'm trying to create a series of bound columns in a RadGridView, and I'm
I am using telerik RadGridView control. I would like to control/style the colors of
I have a RadGridView, a RadDataPager and a RadNumericUpDown all defined in code. Now
I have bound a Telerik RadGridView properly with the first column being a bound
Is there a way in silverlight to detect when a lost focus event is
I have an ImageButton being build inside of radgridview columnn. It is defined as
I am using the Telerik framework for creating a RadGridView with child elements in
I have a RadGridView control in a silverlight project and would like to have
I am using Telerik's RadGridView to display some data. When data in one column

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.