Can you get a DataTable from an ObjectDataSource?

只愿长相守 提交于 2020-01-11 10:41:52

问题


If I have an ObjectDataSource defined at design time, can I get a DataTable from that ObjectDataSource at runtime? I have a method that returns a DataTable that I am using for the Select method property of the ObjectDataSource.


回答1:


I don't really understand your question... are you asking if the object you define in the ObjectDataSource can return a DataTable in the configured select method? Yes, I do it all the time. You can also examine the returned DataTable in the OnSelected event (it is the ReturnValue property of the event object).




回答2:


Yes, but you need to pay attention to when that item has been bound.

If you are talking about a web page:

If you tried to access the DataSource (in your case DataTable) before the page has loaded, it will be null.

If you tried to access it after it has been bound, you'd be able to use the object.



来源:https://stackoverflow.com/questions/389571/can-you-get-a-datatable-from-an-objectdatasource

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!