Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
因为 itemcommand 事件在大多数(如果不是所有)页面/控件初始化/加载事件之后触发。保留在 itemcomment 上修改的会话变量数据(例如添加项目)以便页面可以使用修改后的会话对 itemcommand 做出反应的最佳方法是什么?
您可以在页面生命周期的早期捕获回发:
// id of the control string id = Request.Form["__EVENTTARGET"]; if (!string.IsNullOrEmpty(id) && id.Contains("myControlId")) { string argument = Request.Form["__EVENTARGUMENT"]; ... }
但它既不优雅也不安全。我会遵循 Skowronek 的建议:在 PreRender 上添加更多逻辑。