C# 调用GridView中图像按钮后面的函数

C# 调用GridView中图像按钮后面的函数,c#,asp.net,gridview,C#,Asp.net,Gridview,我在gridview中有两个按钮,但它们在使用“CommandName”后不返回任何事件,我在其中写入函数名,但它不执行任何操作 屏幕截图如下: 这两个按钮是“编辑”和“删除” 以下是片段: <asp:ButtonField ButtonType="Image" ImageUrl="~/wp-content/themes/realia/assets/img/edit pencil change modify alter blue edit icon2.png" CausesValidat

我在gridview中有两个按钮,但它们在使用“CommandName”后不返回任何事件,我在其中写入函数名,但它不执行任何操作

屏幕截图如下:

这两个按钮是“编辑”和“删除”

以下是片段:

<asp:ButtonField ButtonType="Image" ImageUrl="~/wp-content/themes/realia/assets/img/edit pencil change modify alter blue edit icon2.png" CausesValidation="true" Text="Edit" CommandName="Edit_data">
                <ControlStyle Height="30px" Width="30px" />
                </asp:ButtonField>
<asp:ButtonField ButtonType="Image" ImageUrl="~/wp-content/themes/realia/assets/img/500px-Delete_Icon2.png" Text="Delete">
                <ControlStyle Height="30px" Width="30px" />
                </asp:ButtonField>

查看此:will Help按钮上的
OnCommand
事件绑定到哪里了??
protected void Edit_data(object sender, EventArgs e)
    {
        Response.Write("hello");
    }
<asp:GridView ID="gvProduct" runat="server" AutoGenerateColumns="False" DataKeyNames="ID" 
                                    OnRowCommand="gvProduct_RowCommand" Width="100%">
                                    <Columns>
                                        <asp:TemplateField>
                                            <ItemTemplate>
                                                <asp:ImageButton ID="btnEdit" runat="server" CommandName="EditCommand" ImageUrl="~/Images/Grid/edit.png"
                                                     />
                                            </ItemTemplate>
                                                                                        </asp:TemplateField>
                                        <asp:BoundField DataField="ProjectNo" />
                                        <asp:BoundField DataField="OrderLetterNo"  />
                                        <asp:BoundField DataField="Date"  />
                                        <asp:BoundField DataField="Saloon" />
                                        <asp:TemplateField>
                                            <ItemTemplate>
                                                <asp:ImageButton ID="btnDelete" runat="server" CommandName="DeleteCommand" ImageUrl="~/Images/Grid/delete.png" />
                                            </ItemTemplate>
                                                                                        </asp:TemplateField>
                                    </Columns>
                                    </asp:GridView>
protected void gvProduct_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        GridViewRow Row = (GridViewRow)((Control)e.CommandSource).NamingContainer;
        int rowID = Convert.ToInt32(gvProduct.DataKeys[Row.RowIndex].Value);

        if (e.CommandName == "EditCommand")
        {
            EditFunction(rowID);
        }
        else
            if (e.CommandName == "DeleteCommand")
            {
                DeleteFunction(rowID);
            }
    }