This is a migrated thread and some comments may be shown as answers.
GridImageColumn throws exception of 'Object does not match target type' when binding to an interface
3 Answers 35 Views
This is a migrated thread and some comments may be shown as answers.
Mathew
Top achievements
Rank 1
Mathew asked on 18 Mar 2013, 02:01 PM
I have a RadGrid that's using a RadImageColumn to display an image based on the value of a field in the data source, which is working perfectly fine.

However, when my datasource is bound to a collection of an interface type, I'm getting the error "Object does not match target type".

My classes are structures as follows:

interface I
{
    string ImageURL
}
class A : I
{
    string ImageUrl { get { ... } }
}
class B : I
{
    string ImageURL { get { ... } }
}

I'm binding to a datasource that is a collection of items of type I.  What appears to be happening is that when my datasource only contains records of either type A or only records of type B, the grid binds succesfully.  The problem seems to occur when I try to bind to a datasource that contains both types, and only occurs the first time it tries to bind to the second type.  Presumably this might also cause problems with abstract classes, or other derived properties.

3 Answers, 1 is accepted

Sort by
0
Mathew
Top achievements
Rank 1
answered on 19 Mar 2013, 10:15 AM
Has anyone been able to reproduce this issue?  It's only happening with RadImageColumn, not anything else.
0
Radoslav
Telerik team
answered on 21 Mar 2013, 09:57 AM
Hello Mathew,

Indeed I verified that the described behavior exists in the current version of our controls. However I will forward this issue to our developers for further investigation.  At a meantime you can use GridTemplateColumn with places image into its ItemTemplate.

I hope this helps.

Greetings,
Radoslav
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
Mathew
Top achievements
Rank 1
answered on 21 Mar 2013, 11:54 AM
Hi Radoslav, thanks for the response.  Yes, that's exactly what I'm doing to get around the issue at the moment but will look forward to it being fixed in a future release.
Tags
Grid
Asked by
Mathew
Top achievements
Rank 1
Answers by
Mathew
Top achievements
Rank 1
Radoslav
Telerik team
Share this question
or