I set the autogenerate delete and edit button property to true. I want to set delete button to the right of the gridview and when user press the delete button a warning should be display that "Are you sure to delete?" with yes or no tabs. if user press yes then only data should be deleted otherwise no. how i can achive this in asp.net?
Delete operation on gridview
I have datagridview in asp.net as follows.

I set the autogenerate delete and edit button property to true. I want to set delete button to the right of the gridview and when user press the delete button a warning should be display that "Are you sure to delete?" with yes or no tabs. if user press yes then only data should be deleted otherwise no. how i can achive this in asp.net?
I set the autogenerate delete and edit button property to true. I want to set delete button to the right of the gridview and when user press the delete button a warning should be display that "Are you sure to delete?" with yes or no tabs. if user press yes then only data should be deleted otherwise no. how i can achive this in asp.net?
Gaurav GuptaPosted Apr 12, 2013, 2:17 AM
So, replace
<asp:CommandField ShowDeleteButton="True" />
With the below line of code..
<ItemTemplate>
<asp:LinkButton ID="LinkButtonDelete"
ToolTip="Delete with Confirmation" CommandName="Delete" runat="server" OnClientClick="return confirm('Are you sure you want to delete this video?');"/>
ItemTemplate>
asp:TemplateField>
Then, In the Rowcommand event of the gridview you can perform your deleted task after confirmation like this..
protected void VideoList_RowCommand(object source, GridViewCommandEventArgs e)
Hope this will help you...{
try
{
if (e.CommandName == "Delete")
{
// Perform your delete code here...
}
catch
{
}
}
If it helps.. marks as accepted..
Girish BarjePosted Apr 12, 2013, 1:20 AM
You can refer to the following link it has detail code for implementing the confirmation for message on delete.
http://www.codeproject.com/Articles/12666/GridView-Delete-with-Confirmation
Regards
girish Barje