且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何避免使用Session

更新时间:2022-11-21 15:46:03

您可以使用的 ViewState中存储 listeSpecialite 。只要确保理解它是如何工作,确保比赛你所需要的。

You can use ViewState to store listeSpecialite. Just make sure to understand how it works to ensure that match what you need.

视图状态具有其自身的缺点。在B64和负载页面生命周期过程中更多的时间序列化/反序列化,编码/ deocding /恢复页面视图状态等。此外,在默认情况下,ViewState是在一个隐藏字段发送到客户端。这种增加带宽。

Viewstate has its own drawbacks. More process time for serialization/deserialization, encoding/deocding in B64 and for the page lifecycle in load/restore viewstate of the page, etc. Also, by default, viewstate is sent to the client in a hidden field. This increase bandwidth.

无论如何,如果你的列表中有不能坚持你的当前视图我会使用视图状态

Anyway, if your list has not to be persisted out of your current view I would use Viewstate.

编辑:

随着1000项目列表视图状态将hurge。如何从数据库中读取持久化的项目,并保持在ViewState中刚刚添加的项目?你可以检索数据库的项目,从视图状态检索项目,结合并绑定到数据网格。这是另一种策略,以避免在读取数据库的成本和会话视图状态hurge每个回发。

With list of 1000 items viewstate will be hurge. How about read from data base persisted items and keep in viewstate just the added items?. You could retrieve items of database, retrieve items from viewstate, combine and bind to datagrid. It is another strategy to avoid session and hurge viewstate at the cost of read database every postback.

正如我所说的,没有银弹... :-P

As I said, there is no silver bullet... :-P