Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
0
Blazor datagrid use of dynamic list using ExpandoObject
posted

I am trying to databind the following dynamic list to the datagrid. Is this possible? I am converting a datatble to a dynamic list using ExpandoObject.

Kind regards,

Evert van Ballegooie

public static List<dynamic> ListFromDataTable(DataTable dataTable)
{
List<dynamic> tableList = new List<dynamic>();
foreach (DataRow row in dataTable.Rows)
{
var expandoDict = new ExpandoObject() as IDictionary<String, Object>;
foreach (DataColumn col in dataTable.Columns)
{
expandoDict.Add(col.ToString(), row[col.ColumnName]);
}
tableList.Add(expandoDict);
}
return tableList;
}