Posts

Showing posts from December, 2008

Delete Command Twice in GridView

Image
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" /> </asp:GridView> I am getting the DeleteRowById method called which when the delete button in the CommandField is clicked. Doing some Internet research I found this: http://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=105123 However, the workaround isn't right, basically all you need to do is change the <asp:CommandField to: <asp:TemplateField> <ItemTemplate> <asp:ImageButton runat=server id= "ImageButton1" CommandName= "Delete" ImageUrl= "..." CommandArgument='<%# DataBinder.Eval(Container, "RowIndex" ) %>' /> </ItemTemplate> </asp:TemplateField> You don't need to add a code behind