Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
85
Binding to dynamic object
posted

Hello,

In my project, I use Infragistic's XamGrid. My database query result returns me a datatable which I need to bind with Xamgrid's ItemsSource.

MyGrid.ItemsSource = dataTable;

Binding datatable directly to DataGrid is not a problem but I want to convert my datatable to observablecollection. Converting to observable collection will help me in updating the subsequent changes (i.e. Adding/Editing/deleting of Rows from datatable) to UI layer faster. Now the problem is datarow object which is returned to me as part of datatable row collection is not always of the same type. What is returned as datarow depends on what I query and to which datatable in my database. 

Because my datarow Item object type is not fixed I'm not able to use the ObservableCollection (because I need to specify the object type while creating the observable collection)

new ObservableCollection<T>(IEnumerable<T>)

I don't know <T> i.e. what is the datarow object type. In such case, is it possible to create the ObservableCollection and bind it to grid?

If using the ObservableCollection is not possible then what are the other ways to update the UI faster with database changes. (In my case per second around 100 rows may get changed/added/deleted).

Thanks,