绑定源问题 [英] Problem With Binding Source
本文介绍了绑定源问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
hi
我试图将绑定源转换为数据表...但是每次遇到错误时,请帮忙.
hi
i tried to convert from binding source to data table ...but every time i''m getting and error, please help.
objMedSource.DataSource = objMedication;
dtgMedicine.DataSource = objMedSource;//where i showed the binding source to be the data source of data grid
DataTable dttable;
//DataView dv;
//dv = (DataView) dtgMedicine.DataSource;
//dv.DataViewManager = objMedSource;
//dttable = dv.Table.DataSet.Tables[0];
//dttable = ((DataSet)objMedSource.DataSource).Tables[objMedSource.DataMember];
//dttable = (DataTable)objMedSource.DataSource;
dttable = ((DataTable)(dtgMedicine.DataSource)).Clone();
在这里,我在转换过程中出错..我尝试了几种可能的方法.请帮助
here i get error during conversion..i tried several possible ways. please help
推荐答案
您是否要从ObjectDataSource
将数据加载到Datatable
?如果是这样,从技术上讲是可能的,但毫无意义.ObjectDataSource
的作用是declaratively
将数据绑定到控件.在ObjectDataSource
控件可以使用它之前,您需要创建一个方法以将其加载到某些内容(例如DataTable
,或更可能是List<myobject></myobject>
)中.ObjectdataSource
控件不是数据容器.它们只是指向以一种或另一种形式返回数据的方法的一种手段. REF
如果您正在寻找将ObjectDataSource连接到DataTable的方法,请尝试以下操作:
使用Code-后面
Do you mean you want to load data into theDatatable
from anObjectDataSource
? If so, technically it''s possible but pointless. The role of theObjectDataSource
is todeclaratively
bind data to a control. You would need to create a method to load it into something (such as aDataTable
, or more likely aList<myobject></myobject>
) before theObjectDataSource
control could work with it.ObjectdataSource
controls are not data containers. They are simply a means of pointing to a method that returns data in one form or another. REF
If you are looking for Connecting an ObjectDataSource to a DataTable then try the following:
Connecting an ObjectDataSource to a DataTable in Code-behind
这篇关于绑定源问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文