I have a gridview which is like
<asp:TemplateField HeaderText="File Name" SortExpression="FileName">
<ItemTemplate>
<asp:LinkButton ID="lnkname" runat="server" Text='<%#Eval("FileName") %>' CommandName='<%#Eval("FileName") %>'>
</asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
<asp:CommandField ShowDeleteButton="True" >
<ControlStyle ForeColor="Red" />
</asp:CommandField>
Rowcommand part works well. When I click on delete, the control goes to gridview1_rowcommand instead of gridview1_rowdeleting and gives error.
How can I make this work?
It’s be helpful if you showed your two event handlers.
It sounds like you have a row_command method setup to use from the linkbutton. The issue is that a delete is still a row command, and that event is firing first (and your code probably expects a linkbutton command). So you would need to not do anything with that command and then the row_deleting with fire.