【发布时间】:2013-06-24 13:05:56
【问题描述】:
我正在使用数据绑定源,该数据源与列表绑定。现在我将此数据源转换为数据集,但它抛出了如下异常:
无法将“System.Windows.Forms.BindingSource”类型的对象转换为“System.Data.DataSet”类型
我正在编写此代码来将数据源转换为数据集。
if (childCtrl is DataGridView)
{
DataSet ds = new DataSet();
ds = (DataSet)(((DataGridView)childCtrl).DataSource);
ds.WriteXml(@"D:\AverageReporting.xml");
}
那么有什么方法可以将绑定源数据转换为数据集?
【问题讨论】: