Click here to hide categories Click here to show left categories

User: Home          welcome : Guest          Log In / Register here     




Ask Confirmation when delete the record

Ask Confirmation when delete the record from grid view or data grid

There are many conditions where we want to confirm from user that he want to delete the record from database or not when user clicks on delete button in Grid view, datalist or datagrid. Then there is a way to do this with javascript. We will show a alert box.to user that if he clicks on Yes then record will delete, other wise not.

<asp:TemplateField>
<ItemTemplate>
<asp:LinkButtonID="LinkButton1"runat="server"
OnClientClick="return confirm('Are you sure to delete this record?');"
CommandName="Delete">Delete Comment</asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
When user will click on the delete button then he will have to confirm the deletion.If he will click on yes button then the record will be deleted otherwise record will not be deleted.

Share this article   |    Print    |    Article read by 1408 times
Author:
Rohit kakria
I am software developer, moderator of xpode.com
Related Articles:
Related Interview Questions: