Asp.net 中 GridView 在 RowDataBound事件中获取 某列值 的方法

来源:互联网 发布:wind资讯经济数据终端 编辑:程序博客网 时间:2024/06/06 03:57
  ICustomTypeDescriptor item = e.Row.DataItem as ICustomTypeDescriptor;                Service_Prop o = item.GetPropertyOwner(null) as Service_Prop;

其中 Service_Prop 为你的数据对象,

本来EntityDataSourceWrapper 是 不可访问的类型,但是它实现 ICustomTypeDescriptor接口 ,所以 在 事件中 获取一行 的值 就相当于 获取一个对象。

通过对象的属性就能获取到当前行某列的值了。很简单。

关于GetPropertyOwner 方法 不必深究,有兴趣可以去看看msdn

原创粉丝点击