Hi all, Just thought to keep this snippet handy. When you create a gridview from a table and you add delete command in it. Whenever you click the delete command or link , the record gets deleted immediately. If there is a javascript popup confirmation so that you can confirm again to delete it that would be nice.

It is simple just convert the delete command coloumn to a template field, this will add the link button. And add code to the OnClientClick event as shown.

<asp:TemplateField HeaderText="Click to Delete" ShowHeader="False">

 <asp:LinkButton ID="LinkButton1" runat="server" CausesValidation="False"
 CommandName="Delete" Text="Delete" OnClientClick='return confirm("Do you want to delete this record?");'></asp:LinkButton>