2013-01-08 74 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

相關問題