We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Exception in group grid when trying to bind my data source

Thread ID:





65897 Jul 27,2007 05:23 PM UTC Jul 30,2007 06:48 PM UTC WinForms 2
Tags: Grouping
Asked On July 27, 2007 05:23 PM UTC

This exception occures many times when I try to bind my data source. However the grid shows up eventually with no problem. However these exceptions cause my program to run very slow. The type I'm binding to doesn't contain a 'System.String[]' type at all. I wonder where did this come from.....

System.Reflection.TargetInvocationException: Property accessor 'Length' on object 'System.String[]' threw the following exception:'Object does not match target type.' ---> System.Reflection.TargetException: Object does not match target type.
at System.Reflection.RuntimeMethodInfo.CheckConsistency(Object target)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean skipVisibilityChecks)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at System.ComponentModel.ReflectPropertyDescriptor.GetValue(Object component)
--- End of inner exception stack trace ---
at System.ComponentModel.ReflectPropertyDescriptor.GetValue(Object component)
at Syncfusion.Grouping.FieldDescriptor._GetValue(Record record)

haneefm [Syncfusion]
Replied On July 30, 2007 06:12 PM UTC

Hi Stanley

Thank you for your update.

The reason is that you try to bind a IList with list of different derived class objects( obj1 and obj2). When you try to bind a BindingList(any List) with list of derived class objects, Grid will start binding the list of object of type same as the type of first item in the list. Then it will expect the remaining objects in the list to be of same type. You can bind the different derived class objects(derived from same base or abstract class) to the same Grid, you need to bind the grid to the BaseClass object, since derived class objects can be refered by its BaseClassType object. In your sample, you can achieve this by binding the empty BindingList to the grid in the form load or anywhere before populating the BindingList.

Here is the modified sample:

Best regards,

Replied On July 30, 2007 06:48 PM UTC

Thanks! It works fine now.


This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon