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

Binding to DataTable when cell values are a custom type

Say I have a bunch of objects of type Foo and I create a System.Data.DataTable where I add a couple columns like: // START CODE SNIPPET table.Columns.Add("FooColumn1", typeof(Foo)); table.Columns.Add("FooColumn2", typeof(Foo)); // and then add a few rows: for ( int i=0; i < 50; i++ ) { table.Rows.Add(table.NewRow()); for ( int j=0; j < table.Columns.Count; j++ ) { Foo foo = new Foo(); foo.SomeProperty = rand.Next().ToString(); table.Rows[i][j] = field; } } // now assign the datasource gridGroupingControl1.DataSource = table; //END CODE SNIPPET the problem is that I get jillions of exceptions thrown like this: catched at Syncfusion.Grouping.FieldDescriptor.GetValue(Record record) in :line 0 How can I handle the processing myself so that I can tell it how to display a Foo in a cell (assume that there is some processing I need to do for each Foo such as call a custom method or perform some string manipulation)... Thanks - Daniel

2 Replies

Administrator July 14, 2004 01:26 PM UTC

Hi Daniel, I created a sample for the scenario you described and I found a bug in the FieldDescriptor class. I have that fixed now. If you submit a direct-trac incident we can send you a private patch. With that fix you can display custom types. Just make sure not to use public field in that type. Instead use public properties. I attached the sample form I created. With the fix, you can then add columns to the table descriptor in the form "ColumnName.PropertyName". Form1_9412.zip Stefan

DC Daniel Chait July 14, 2004 03:32 PM UTC

thanks - I created an incident (#12397) for this. - daniel
Loader.
Live Chat Icon For mobile
Up arrow icon