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. Image for the cookie policy date
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

IBindingLIst DataSource problem, plese help me

Thread ID:





12950 Apr 16,2004 12:26 AM UTC Apr 18,2004 09:53 AM UTC WinForms 2
Tags: GridControl
Administrator [Syncfusion]
Asked On April 16, 2004 12:26 AM UTC

Hello, I have a problem with GridDataBoundGrid: I''m using a custom DataSource of a collection that implements IBindingList. The collection contains Class Person''s objects, this following is class Person: public enum EGender { Man = 1, Woman } public class Person { private string name; private EGender gender; public string Name { get { return this.name; } set { this.name = value; } } public EGender Gender { get { return this.gender; } set { this.gender = value; } } } I construct a DataSource for the "Gender" Column . DataTable table = new DataTable(); table.Columns.Add("Value", typeof(EGender)); table.Columns.Add("Description", typeof(string)); DataRow row = table.NewRow(); row["Value"] = EGender.Man; row["Description"] = "I''m a man"; table.Rows.Add(row); row = table.NewRow(); row["Value"] = EGender.Woman; row["Description"] = "I''m a woman"; table.Rows.Add(row); gridDataBoundGrid1.Binder.InternalColumns["Gender"].StyleInfo.DataSource = table; gridDataBoundGrid1.Binder.InternalColumns["Gender"].StyleInfo.ValueMember = "Value"; gridDataBoundGrid1.Binder.InternalColumns["Gender"].StyleInfo.ValueMember = "Description"; The problem: When I change the value of gender(for example, select "I''m a woman"), there is a exception "Object type can not be converted to target type". if my collection implements ITypedList interface, I will catch a exception "Invalid cast from ystem.Int32 to EGender" please help me, thank u very much

Administrator [Syncfusion]
Replied On April 16, 2004 04:58 AM UTC

I assume the Gender column in the grid''s DataSource is also of type EGender, correct? If so, try also setting; gridDataBoundGrid1.Binder.InternalColumns["Gender"].StyleInfo.CellValueType = typeof(EGender);

Administrator [Syncfusion]
Replied On April 18, 2004 09:53 AM UTC

thank u very much! I have already added gridDataBoundGrid1.Binder.InternalColumns["Gender"].StyleInfo.CellValueType = typeof(EGender); to my code, it does not work either, I add a Breakpoint at the PropertyDescriptor.SetValueSetValue( object component, object value ); Method the value is a Int32 type object which value is 1 or 2, is the value passed by GridDataBoundGrid?If I don''t construct a DataSource for the "Gender" Column, the value will be a EGender type and the value will be {EGender.Man} or {EGender.Woman} (PS:My program returns a custom class named MyPropertyDescriptor : PropertyDescriptor collentcion in ITypedList.GetItemProperties Method, so I can watch the value passed by Grid) please help me... thanks...


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

Live Chat Icon For mobile
Live Chat Icon