i am having two buttons in the gridview but they dont return anything event after using the \"CommandName\" in which i write the function name but it does not do anything.
<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>
and here is the code behind:
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);
}
}