samedi 28 février 2015

C# show data of ExpandoObject - Cannot convert lambda expression to type '…' because it is not a delegate


Vote count:

0




I have this method:



public ActionResult dataGrid()
{
List<ExpandoObject> list = new List<ExpandoObject>();

using (OdbcCommand DbCommand = repODBC.dbConnection.CreateCommand())
{
DbCommand.CommandText = "Select * From MyTable";
OdbcDataReader reader = DbCommand.ExecuteReader();

while (reader.Read())
{
dynamic obj = new ExpandoObject();
obj.name="Peter";
obj.num=123;
obj.id=1;
list.Add(obj);
}

return View(list);
}
}


I try to access data this way. I use Grid.Mvc... :



@Html.Grid((IEnumerable<System.Dynamic.ExpandoObject>)Model).Columns(columns =>
{
columns.Add(m => m.id).Titled("ID");
columns.Add(m => m.name).Titled("Name");
columns.Add(m => m.num).Titled("OS").Filterable(true);
})


but i get this error: Cannot convert lambda expression to type 'GridMvc.Columns.IGridColumn' because it is not a delegate


How can I add columns to grid to show data of ExpandoObject?



asked 1 min ago







C# show data of ExpandoObject - Cannot convert lambda expression to type '…' because it is not a delegate

Aucun commentaire:

Enregistrer un commentaire