This is a migrated thread and some comments may be shown as answers.

bind to IEnumerable<IDictionary<string, object>>

2 Answers 145 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Maxim
Top achievements
Rank 1
Maxim asked on 15 May 2012, 04:59 PM
Hi,
Is there a way to bind to IEnumerable<IDictionary<stringobject>>.

Thanks

2 Answers, 1 is accepted

Sort by
0
Julian Benkov
Telerik team
answered on 17 May 2012, 02:14 PM
Hello Maxim,

Thank you for writing.

This is not a supported functionality in RadGridView. You can bind to IEnumerable<T>, where T object must contain public properties to bind properly to RadGridView control. More information about binding you can find in our online documentation.

I hope this helps. 

Kind regards,
Julian Benkov
the Telerik team
RadControls for WinForms Q1'12 release is now live! Check out what's new or download a free trial >>
0
Holger Boskugel
Top achievements
Rank 2
answered on 23 May 2012, 01:39 PM
Hello Maxim,

how Julian stated, wrap your IEnumerable<IDictionary<string, object>> with a Wrapper.
 
As I suppose, your IEnumerable are the rows and the pairs in your IDictionary are the "named" or mapped values for the Cells, where the Key is the Name, UniqueName or FieldName of the Column? In this case you have two ways:

a) Wrapper which creates a List with dynamic created objects (Key = Property) or
b) Wrapper of DataTable which easily? copies the pairs to the DataTable
c) Wrapper of IDataReader which get consumed by the Load method of a DataSet

where I mean the solution c) is simple to implement if you provide the related metadata for the "Fields" (your pair Keys). So you read directly from IEnumerable instance. Drawback is the lot of implementation of Methods from the interface. Read() will be connected to MoveNext() of IEnumerator<IDictionary<string, object>>, Values read from Current of the Enumerator and the access with FieldIndex of IDataReader goes via a metadata list of columnnames or columnmetadata collection (can be a List<DataColumn> or better KeyedCollection<DataColumn>). So also GetName and GetOrdinal of the interface can be supported.

As alternate to List<DataColumn> you can hold a none filled DataTable, where you only add the Columns for holding columns metadata.

Hope that helps!


Regards from Leipzig

Holger
Tags
GridView
Asked by
Maxim
Top achievements
Rank 1
Answers by
Julian Benkov
Telerik team
Holger Boskugel
Top achievements
Rank 2
Share this question
or