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

[Solved] 4004 error when assigning DataContext -- new for build 1208 not in 1103

2 Answers 60 Views
GridView
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
arthurd
Top achievements
Rank 1
arthurd asked on 11 Dec 2009, 06:53 PM
I was using 2009 3 1103. I just upgraded to 2009 3 1208. Now I get error 4004 InvalidCastException.

I have a grid that is bound to a List<DemographicData> but it actually contains several types of objects whose base class is DemographicsData.

For example:

BaseData
  DemographicData derived from BaseData
    PersonalDemographicData derived from DemographicData
    EmployerDemographicData derived from DemographicData
    FamilyDemographicData derived from DemographicData

List<DemographicData> has PersonalDemographicData, EmployerDemographicData , and FamilyDemographicData

Calling "grid.DataContext = demographicdata" now crashes with 4004.

If the List only contains objects of one type (Personal, Employer, or Family) then it works fine. But if you have 2 or more types, it breaks.

The grid has AutoGenerateColumns="False" and the only 2 columns in the grid that are bound are bound to properties of BaseData.

Any ideas?

Looks like the grid is assuming that the object types of all entries must be the same.

2 Answers, 1 is accepted

Sort by
0
arthurd
Top achievements
Rank 1
answered on 11 Dec 2009, 06:57 PM
BTW, I tried casting the objects to DemographicData before adding to the List<> and I get the same results.
0
Stefan Dobrev
Telerik team
answered on 15 Dec 2009, 01:53 PM
Hello arthurd,

This is a bug we introduced within our service pack release. We are currently working on a fix that will be available in the next latest internal build.


All the best,
Stefan Dobrev
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.
Tags
GridView
Asked by
arthurd
Top achievements
Rank 1
Answers by
arthurd
Top achievements
Rank 1
Stefan Dobrev
Telerik team
Share this question
or