Hello:
I am trying to fetch some solutions to my problem here:
Anyone out there with a useful answer, please help out?
I want to use the mvccontrib (
http://mvccontrib.codeplex.com) to auto
generate grid by passing the DataTable to the Grid. At the moment,the
Grid does not support this.
Grid takes in IEnumerable(Of T) and auto generate columns. Is there
some way I could achieve this by say, passing DataTable. Or How do I
convert the DataTable to IEnumerable(Of T).
The DataTable is completely Dynamic and I wouldnt be able to tell the
number of columns or names of the columns. Since the DataTable is very
dynamic , hence the number of columns are not fixed so its just about
any DataTable.
How do I go about this ?
I want to convert a Dynamic DataTable to IEnumerable(Of T). Or Is
their any other better way ???
I have tried the following approaches but couldnt go any far :
1) One approach was to use .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 have tried to pass IEnumerable(Of SampleDynamicObject) but the
BuildColumns() method is not able to find out the propreties
dynamically added on to it.
2) Second approach to modifing the AutoGenerateColumns() method to
work with DataTable, But it looks impossible since a Grid Get
initialize using IEnumerable(Of T) and all the calls on grid for
method uses IEnumerable(Of T). So talking about converting DataTable
to IEnumerable(Of T) and the DataTable being dynamic, i don't know the
structure at design time at present, So its probably not possible to
write any specific class to create a object and convert DataTable to
IEnumerable(Of T).