A GridView CommandField of type Image causes a double submit

I can’t believe this issue is marked as Closed (fixed). The bug causes two requests to be made from when clicking an ImageButton in a CommandField, which can do nasty things if you are deleting rows. Apparently the “fix” is to not use ImageButtons in CommandFields. Brilliant. Granted it is fairly straight forward to do with a TemplateField, but that is hardly fixing the original problem.

If you are really keen on sticking to CommandFields you can do something terribly hacky like this:

<asp:CommandField CausesValidation="false" 
  DeleteText="&lt;img border='0' src='Images/icon-delete-12x12.png' /&gt;"
  ShowDeleteButton="true" ButtonType="Link" />

Comments