如何进行数据绑定的GridView到ExpandoObject [英] How to databind a gridview to an ExpandoObject
问题描述
当我尝试数据绑定的ASP.NET GridView控件
到的IEnumerable< ExpandoObject>
使用<$ C 。$ 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):数据绑定:System.Dynamic.ExpandoObject'不包含名为'STOREID'属性。
System.Web.HttpException (0x80004005): DataBinding: 'System.Dynamic.ExpandoObject' does not contain a property with the name 'StoreID'.
任何人都知道我怎么能数据绑定到<?code> 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屋!