我想判断一个类是否具有DataSource属性,然后对其赋值,下面有一段代码,不太明白
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
{
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
...全文
相关推荐
C#ComboBox控件“设置 DataSource 属性后无法修改项集合”的解决方法
DataSource属性是.NET Framework中许多控件都具备的一个属性,用于将控件与数据源绑定。
解决WinForm设置 DataSource 属性后无法修改项集合
**创建临时集合**:另一种方法是先将原始数据源复制到一个新的集合中,然后将这个新的集合作为控件的数据源。这种方法可以在不影响原始数据的情况下进行修改,但需要额外的内存空间来存储临时集合。
DataSource接口介绍与使用
JDBC1.0是原来是用DriverManager类来产生一个对数据源的连接。JDBC2.0用一种替代的方法,使用DataSource的实现,代码变的更小巧精致,也更容易控制。
spring为java.util.Properties类型的属性进行赋值过程解析
例如,在上面的示例代码中,我们定义了一个DataSource Bean,其中包括了一个Properties类型的属性,我们使用<props>标签来定义了四个键值对:user、password、jdbcUrl
C# ComboBox控件“设置 DataSource 属性后无法修改项集合”的完美解决方法
当我们将DataSource属性设置为一个数据源(如DataTable、List或其他集合对象)时,ComboBox的行为会发生变化,可能导致无法直接修改其Items集合。


