SortedBindingList and TableStyles property of DataGrid not working

SortedBindingList and TableStyles property of DataGrid not working

Old forum URL: forums.lhotka.net/forums/t/4025.aspx


JimBalo posted on Tuesday, December 11, 2007

Hi,

I am using a the SortedBindingList to sort a collection of business objects and I am using the SortedBindingList as the datasource for a DataGrid (compact framework). 

The problem is that I cannot get any TableStyles to take effect when I do this.  If I bind the grid directly to my business object collection, it works fine.  I believe it has to do with the MappingName property of the table style, but I have no idea what to set it to.  The documentation says to specify the name of the table in the dataset, but that does not apply here. 

Any help on this would be greatly appreciated - I am really stumped on this one.

Thanks,

Jim

Ps. While researching this, I came accross people who suggested to not use business objects but use DataSets or similar instead.  If that is the only route, can somone point me to some good generic class to create a datatable or similar from a business object collection?

 

JoeFallon1 replied on Wednesday, December 12, 2007

CSLA comes with a class called Object Adapter. The comment reads:

''' An ObjectAdapter is used to convert data in an object or collection into a DataTable.

Joe

JimBalo replied on Wednesday, December 12, 2007

Thanks for the reply - I'll have a look at that if there is no way to the the TableStyles to work right with the collection directly...

Thanks,

Jim

P.s. I am not using the full CSLA in this project - so far I am only using the SortedBindingList.  The app is a compact framework application (Pocket PC 2003), so I am not sure if the Object Adapter will compile (due to limitations in the compact framework).

 

JimBalo replied on Wednesday, December 12, 2007

I found the solution:

I used dataGrid.DataSource.GetType().Name and used that value as the MappingName.  The value for the SortedBindingList is: "SortedBindingList`1"

Jim

Copyright (c) Marimer LLC