如何将gridview数据绑定到ExpandoObject [英] How to databind a gridview to an ExpandoObject
问题描述
当我尝试使用<$ c数据绑定ASP.NET GridView
到 IEnumerable< ExpandoObject>
$ c> ObjectDataSource ,我得到以下异常。
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'不包含名称为StoreID的属性。
System.Web.HttpException (0x80004005): DataBinding: 'System.Dynamic.ExpandoObject' does not contain a property with the name 'StoreID'.
任何人都知道我可以将数据绑定到 ExpandoObjects
?
Anyone know how I could databind to ExpandoObjects
?
推荐答案
开源框架 Impromptu-Interface 可以做到这一点。它具有通过传入属性名称 - >类型的字典来暴露用于反射的动态对象属性的方法。
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))));
这篇关于如何将gridview数据绑定到ExpandoObject的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!