数据表保存到会话状态丢失事件处理程序 [英] DataTable saved to Session state loses event handlers

查看:168
本文介绍了数据表保存到会话状态丢失事件处理程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我从对TableNewRow事件的事件处理程序的强类型DataSet的DataTable(初始化一些日期字段)

I have a DataTable from a strongly-typed DataSet that has an event handler on the TableNewRow event (to initialize some date fields)

当我保存这个表分成会话状态,事件处理火灾通常直到表的序列化。在随后的请求时,我检索表从会话状态,事件处理函数不再火灾。

When I save this table into Session state, the event handler fires normally until the table's serialized. On subsequent requests when I retrieve the table from Session state, the event handler no longer fires.

这是正常的行为,我希望重新连接上反序列化事件处理程序?如果是这样,因为没有办法检查事件处理程序是否已经添加,什么是做重装适当挂钩?

Is this normal behavior, and I'm expected to rewire the event handlers on deserialize? If so, since there's no way to check whether the event handler has been added, what is the proper hook for doing the rewiring?

推荐答案

根据您的序列化,你可以尝试通过OnDeserialized属性来设置事件处理程序的 http://stackoverflow.com/a/4172266/1236044

Depending on your serialization, you can try to set the eventhandler through OnDeserialized attribute http://stackoverflow.com/a/4172266/1236044

有关XML序列化也许你可以尝试这样的事:

For Xml serialization, maybe you can try something like this :

public override void ReadXml (XmlReader reader)
{
    base.ReadXml(reader);
    NewRow+=....
}

这篇关于数据表保存到会话状态丢失事件处理程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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