在listview itemcommand ASP.NET上持久保存会话变量的最佳方法

时间:2010-08-06 18:43:54

标签: asp.net session listview itemcommand

由于itemcommand事件在大多数(如果不是全部)页面/控制init / load事件之后触发。保留在itemcomment上修改的会话变量数据的最佳方法是什么(例如添加项目),以便页面可以使用修改后的会话对itemcommand做出反应?

1 个答案:

答案 0 :(得分:0)

您可以在页面生命周期的早期捕获回发:

// id of the control
   string id = Request.Form["__EVENTTARGET"];  

   if (!string.IsNullOrEmpty(id) && id.Contains("myControlId"))  
   {
        string argument = Request.Form["__EVENTARGUMENT"];
        ...
   }

但它既不优雅也不安全。我会遵循Skowronek的建议:在PreRender上加入更多逻辑。