从 SqlDataSource 或 GridView 读取数据
我在 Web 表单上有 SqlDataSource 和 GridView。 GridView.DataSourceID = mySqlDataSource。
当我调用 myGridView.DataBind() 时,所有数据都成功绑定到页面上。
如何从 mySqlDataSource 或 myGridView 对象中读取已获取的数据作为 DataTable 或 DataView?谢谢
I have SqlDataSource and GridView on web form. GridView.DataSourceID = mySqlDataSource.
When I call myGridView.DataBind(), all data successfully bind on the page.
How is it possible to read already got data from mySqlDataSource or myGridView objects as DataTable or DataView? Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
可以使用Gridview控件的FindControl属性读取GridView中的数据。例如,用于读取网格中复选框列中设置的值。
The data in the gridview can read by using FindControl property of Gridview control. For example, for reading values set in the Checkbox column in the grid.
如果您的数据集不是很大,您可以将其存储在
Session
中,将GridView
绑定到Session
数据,然后重新在其他 Web 对象中使用Session
数据。然后你的代码看起来像这样(你必须原谅任何小的不准确之处——我现在离开了我的开发框):
Provided your data set isn't gigantic, you could store it in the
Session
, bind yourGridView
to theSession
data, and then re-use theSession
data in your other web objects.Your code would then look something like this (you'll have to forgive any minor inaccuracies -- I'm away from my development box at the moment):