我想判断一个类是否具有DataSource属性,然后对其赋值,下面有一段代码,不太明白

YiYanXiYin YiYanXiYin 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
private void BoundControl_DataBound(object sender,System.EventArgs e)
{
if (HasParentControlCalledDataBinding) return;
Type type = sender.GetType();
_datasource = type.GetProperty("DataSource");
if (_datasource == null)
throw new NotSupportedException("分页控件要求表现控件必需包含一个DataSource。");
object data = _datasource.GetGetMethod().Invoke(sender,null);
_builder = Adapters[data.GetType()];
if (_builder == null)
throw new NullReferenceException("没有安装适当的适配器来处理下面的数据源类型:"+data.GetType());
_builder.Source = data;
}

_builder这个是什么类型?我仅仅需要对DataSource赋值即可

全文http://www.6to23.com/s11/s11d8/s11d8d1/2004421154352.htm

...全文

相关推荐

评论 6
收藏 已收藏
分享
返回顶部
YiYanXiYin
C# 111,130 成员 642,540 内容