2011-12-21 28 views

回答

0

我不假裝這個解決方案是好的,但你可以使用jQuery和隱藏取消按鈕:

$(document).ready(function() { 
     $(this).keypress(function(e) { 

      if (e.keyCode == 27) { 
       e.preventDefault(); 
       $('#<%= cancelButton.ClientID %>').click(); 
      } 
     }); 
    }); 

只意味着,當用戶點擊逃跑,隱藏按鈕被點擊。

<div style="display:none"> 
    <asp:Button runat="server" ID="cancelButton" OnClick="CancelButton_Click"/> 
</div> 

在按鈕的點擊事件,你取消了編輯模式(給出的GridView控件具有ID =「網格」):

protected void CancelButton_Click(object sender, EventArgs e) 
{ 
    if (grid.EditIndex != -1) 
    { 
     grid.EditIndex = -1; 
     grid.DataBind(); 
    } 
} 

不幸的是,我不知道如何訪問直接在gridview行中取消按鈕。

+0

對不起,但這並不適用於我 – 2012-01-25 08:24:09

+0

什麼沒有工作? – AGuyCalledGerald 2012-01-25 09:30:42