asp.net怎樣添加GridView的RowCommand事件

第一種方法:

選中GridView控件,然後選中屬性工具中的時間按鈕(圖標是一個閃電),然後找到RowCommand,然後雙擊,自動生成了RowCommand事件。

第二種方法:

在源代碼視圖中
<asp:GridView ID="GridView1" runat="server" OnRowCommand="GridView1_RowCommand">
</asp:GridView>

這句話:OnRowCommand="GridView1_RowCommand" 是添加OnRowCommand事件
然後在你的邏輯代碼中寫入
protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
    {
          //這裏爲你要寫的代碼
    }
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章