开发者

How to databind a gridview to an ExpandoObject

开发者 https://www.devze.com 2023-02-05 08:38 出处:网络
When I try to databind an ASP.NET GridView to an IEnumerable<ExpandoObject> using an ObjectDataSource, I get the following exception.

When I try to databind an ASP.NET GridView to an IEnumerable<ExpandoObject> using an ObjectDataSource, I get the following exception.

System.Web.HttpException (0x80004005): DataBinding: 'System.Dynamic.ExpandoObject' does not contain a property with the name 'StoreID'.

Anyone know how I could databind to Expa开发者_如何学CndoObjects?


The opensource framework Impromptu-Interface can do this. It has a method for exposing dynamic object properties for reflection by passing in a dictionary of property names->types.

IEnumerable<dynamic> tProxiedObject = listOfExpandos.Select(x=>Impromptu.ActLikeProperties(x, x.ToDictionary(k=>k.Key,v=>typeof(object))));
0

精彩评论

暂无评论...
验证码 换一张
取 消