I\'m using Rob Conery\'s Massive ORM, and I haven\'t been able to bind the resulting ExpandoObject
to a GridView
.
I did find another Stacko
I came to this thread after researching on the same topic, I found no solution but constructed my own as I desperately needed this one. So here is my solution without going POCO that really works.
// Fill "list" with your dynamic objects.
// cast a dynamic object to dictionary so we get the properties from it.
var props = list[0] as IDictionary;
// create a datatable
var table = new System.Data.DataTable();
foreach (var c in props.Keys)
table.Columns.Add(new DataColumn(c));
foreach (var o in list)
{
var row = table.NewRow();
var op = o as IDictionary;
foreach (var p in op.Keys)
{
row[p] = op[p];
}
table.Rows.Add(row);
}
And simply bind this table to your grid!
I tested it and it worked for me.