Hi,
In My project i want to use the mvccontrib (http://mvccontrib.codeplex.com) to auto generate grid by passing the DataTable to the Grid. Currently Grid does not support this.
Grid takes IEnumerable(Of T) and auto generate columns. Is their any way i can achieve this by passing DataTable. Or How do i convert the DataTable to IEnumerable(Of T). My DataTable is completely Dynamic i don't know number of columns or names of the columns at design time. DataTable completely dynamic number of columns are not fixed it just any DataTable.
How can i achieve this?
In Short i want to convert Dynamic DataTable to IEnumerable(Of T). Or Is their any better way.
I tried following way
1) One way i tried is using .net 4.0 Dynamic, DynamicObject and ExpandoObject I created a dynamic class as shown here http://msdn.microsoft.com/en-us/library/system.dynamic.dynamicobject.trygetindex.aspx. I trid passing IEnumerable(Of SampleDynamicObject) but BuildColumns() method is not able to find out the proprieties dynamically added on to it.
2) I think Second way to modify the AutoGenerateColumns() method to work with DataTable, But it looks impossible as Grid Get initialize using IEnumerable(Of T) and all the call on grid for method is using IEnumerable(Of T). So it's come down to converting DataTable to IEnumerable(Of T) and my DataTable are dynamic i don't know their structure at design time So i can't write any specific class to create a object and convert DataTable to IEnumerable(Of T).
Does any one have any better way out on this.
Thanks
Sandy