c#
  • asp.net
  • 2016-04-08 77 views 1 likes 
    1
    <asp:TemplateField HeaderText="Modify"> 
        <ItemTemplate>         
         <asp:Button ID="btnDelete" runat="server" Text="Delete" 
          CommandName="Delete" 
          CommandArgument='<%# ((GridViewRow)Container).RowIndex %>' > 
         </asp:Button> 
        </ItemTemplate> 
    </asp:TemplateField> 
    

    如果點擊刪除按鈕RowDeleting事件被觸發。如何點擊刪除按鈕觸發RowCommand事件我需要做什麼?如何在gridview中點擊按鈕時觸發RowCommand

    回答

    2

    在後面的代碼,在 'GrdView_RowCommand' 活動檢查的CommandName像下面,

    protected void GrdView_RowCommand(object sender, GridViewCommandEventArgs e) 
        { 
         if (e.CommandName == "Delete") 
          { 
           //do something 
          } 
        } 
    

    Refer Link1

    Refer Link2

    相關問題