Delete Command Twice in GridView

The delete command is being called twice for each click on delete. What do I mean by this? With this code:

<asp:GridView runat="server" DeleteMethod="DeleteRowById" ...>
    <asp:CommandField ShowDeleteButton="True" />

I am getting the DeleteRowById method called which when the delete button in the CommandField is clicked. Doing some Internet research I found this:

However, the workaround isn't right, basically all you need to do is change the <asp:CommandField to:

     <asp:ImageButton runat=server id="ImageButton1" CommandName="Delete" ImageUrl="..."
    CommandArgument='<%# DataBinder.Eval(Container, "RowIndex") %>' />

You don't need to add a code behind event handler for the ImageButton Command event.



Popular posts from this blog

Yet once more into the breech (of altered programming logic)

Simple WP7 Mango App for Background Tasks, Toast, and Tiles: Code Explanation

How to convert SVG data to a Png Image file Using InkScape