gridview 在viewstate 中保存数据吗? [英] does gridview save data in viewstate?

查看:24
本文介绍了gridview 在viewstate 中保存数据吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨我将 DataTable 绑定到 gridview.我想在一些回发事件中使用数据表,我想使用视图状态.gridview 在viewstate 中保存数据吗?如果没有,最好的方法是什么.

hi i bind a DataTable to a gridview. i want to use the DataTable in some postback event, and ii want to use viewstate. does gridview save data in viewstate? if no what is the best way to do this.

(完整故事:我有一个源自标准 asp.net gridview 的自定义 gridview,我在标题中放了一个按钮将数据导出到excel,我想使用保存在viewstate中的数据导出到excel)

(full story : i have a custom gridview derived from standard asp.net gridview, and i put a button in header to export data to excel, i want to use data saved in viewstate to export to excel)

谢谢

推荐答案

简短的回答是肯定的,GridView 中显示的信息,很像任何控件的当前状态,都存储在 ViewState 中.但是,我认为自己从 WebControl 可用的 ViewState 集合中获取这些数据并不容易(如果可能的话).相反,ASP.NET 在生命周期中运行事件处理程序之前从 ViewState 填充值,因此如果您在处理程序中询问您的 GridView 对象服务器端,您应该看到单元格的当前值.

The short answer is yes, information shown in the GridView, much like the current state of any control, is stored in ViewState. However, I do not think it is easy, if even possible, to get to this data yourself out of the ViewState collection that is available to WebControls. Instead, ASP.NET populates values from ViewState before running event handlers in the lifecycle, so if you interrogate your GridView object server-side in a handler, you should see the current values of the cells.

这篇关于gridview 在viewstate 中保存数据吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆