Quantcast
Channel: Telerik Forums RSS
Viewing all articles
Browse latest Browse all 94857

List of dynamic objects as DataSource

$
0
0

I'm using Telerik WinControls 2014.3.1104.40 in a C# environment.

I have a gridview that has a number of preset columns, as well as zero or more additional, user-defined columns. I need a way to load this data into the grid.

Currently, I am trying to use C# "dynamic" objects, in hope that the FieldName property of each column will access that field of the dynamic object; but the grid does not appear to load anything from a list of dynamic objects.

There should be data loaded into the ​cells, but they show up blank. Here is a sample of the code that is not working:

privatevoidLoadData()
{
    radGridView1.DataSource = newList<dynamic>()
    {
        CreateDynamicObject(1),
        CreateDynamicObject(2),
        CreateDynamicObject(3),
    };
}
 
privatedynamic CreateDynamicObject(intid)
{
    dynamic ret = newExpandoObject();
    ret.Id = id;
    ret.Prop1 = "Property 1: "+ id;
    ret.Prop2 = "Property 2: "+ id;
    returnret;
}

If List<dynamic> data sources are not supported, what other method would be most similar?


Viewing all articles
Browse latest Browse all 94857

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>