2013-01-08 73 views
0

我有一个UserControl,其中包含gridview.I注册这个usercontrol到一个页面aspx normal.But它设置str_btn一直null当我按下选择在GridView。如何从代码隐藏中获取UserControl中的GridView事件

if(!Page.IsPostBack) 
{ 

} 
else 
{ 
    string str_btn = null; 
    if (Request.Form.Keys[Request.Form.Keys.Count - 1]!=null) 
     str_btn=Request.Form.Keys[Request.Form.Keys.Count - 1].ToString(); 
    if(!string.IsNullOrEmpty(str_btn)) 
     handleClick(str_btn); 
} 

如何从aspx页面在usercontrol中获取Gridview事件?

感谢您的帮助。

+0

哪里是在你的代码的用户控制..?你怎么加载/注册用户控件..?你能否请出示与你的问题有关的相关代码......? – MethodMan

+0

感谢您的支持,兄弟。我有2个链接详细解释这个问题。 http://stackoverflow.com/questions/14189851/cant-access-gridview-event-at-usercontrol-by-codebehind/14190246#comment19673274_14190246 – Brian

+0

http://stackoverflow.com/questions/14150848/get-gridview-in-多用户控制从代码隐藏/ 14150889#comment19599867_14150889 – Brian

回答

0

只需在设计模式中选择“Gridview”并打开它的属性即可。

现在只需点击以下中给出图像事件图标:

enter image description here

后,无论事件,你只是想生成上,你只需要双击。例如。这里已经生成了“RowDeleting”和其他事件。

现在,如果您想为“Rowdeleted”生成事件,只需双击该“Rowdeleted”的右侧。

enter image description here

这都是事件,它的代码将在cs文件可用有关。

如果您想了解更多的只是请点击此链接GridView Events

相关问题