how to implement delete confirmation in datagrid

D

DrData

I'm working on an ASP.Net application written in C#. On one page,
there are several datagrid controls used to display, edit and delete
detail records relating to the master record also displayed on that
page. Each row in each datagrid includes a Delete button (added at
runtime by the code-behind page as a ButtonColumn) and an Edit button
(added at runtime by the code-behind page as an EditCommandColumn).
What is the quickest, easiest and most reliable way to add delete
confirmation functionality, so that when the user clicks the Delete
button, they must take some further action before the record is
actually deleted?

Thanks in advance for any help anyone can offer.

I'm operating under the following constraints:
1. This large application was written by a consultant, who did not
document his work, and who is no longer available for modifications
or bug corrections.
2. I'm a VB veteran but a relative newcomer to C# and the Dot Net
environment, a bit overwhelmed by it, and trying to get the job done
using the most straightforward & well-documented controls and
coding techniques.
3. All of our programmers (including those with substantial C#/Dot Net
experience) have had tremendous problems debugging the Java-script
code (both embedded in the C# source and generated by some of the
consultant's proprietary routines) this application relies on, and so
we're endeavoring to minimize its use as we correct and expand the
application.
4. In the _ItemCreated method for each datagrid, there is already some
Java-script specified for the "onclick" event, and so if implementing
delete confirmation requires adding more Java-script in the same
place, it will have to co-exist with the existing Java-script.
 
K

Ken Cox [Microsoft MVP]

Here's a good (and free) control to start with:

Confirmed Buttons Control

"This is a collection of buttons which request confirmation from the user
before posting back to the server. Included is a normal button, a link
button, and an image button. Also included are two DataGrid columns which
subclass EditCommandColumn and ButtonColumn which add confirmation to the
buttons"


http://www.metabuilders.com/Tools/ConfirmedButtons.aspx

DrData said:
I'm working on an ASP.Net application written in C#. On one page,
there are several datagrid controls used to display, edit and delete
detail records relating to the master record also displayed on that
page. Each row in each datagrid includes a Delete button (added at
runtime by the code-behind page as a ButtonColumn) and an Edit button
(added at runtime by the code-behind page as an EditCommandColumn).
What is the quickest, easiest and most reliable way to add delete
confirmation functionality, so that when the user clicks the Delete
button, they must take some further action before the record is
actually deleted?

Thanks in advance for any help anyone can offer.

I'm operating under the following constraints:
1. This large application was written by a consultant, who did not
document his work, and who is no longer available for modifications
or bug corrections.
2. I'm a VB veteran but a relative newcomer to C# and the Dot Net
environment, a bit overwhelmed by it, and trying to get the job done
using the most straightforward & well-documented controls and
coding techniques.
3. All of our programmers (including those with substantial C#/Dot Net
experience) have had tremendous problems debugging the Java-script
code (both embedded in the C# source and generated by some of the
consultant's proprietary routines) this application relies on, and so
we're endeavoring to minimize its use as we correct and expand the
application.
4. In the _ItemCreated method for each datagrid, there is already some
Java-script specified for the "onclick" event, and so if implementing
delete confirmation requires adding more Java-script in the same
place, it will have to co-exist with the existing Java-script.
 
S

Steve C. Orr [MVP, MCSD]

Here is an entire article written on that specific topic:
http://www.dotnetjunkies.com/HowTo/1E7FEE4A-795C-4D33-A135-843EB07C94A8.dcik

--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://Steve.Orr.net


DrData said:
I'm working on an ASP.Net application written in C#. On one page,
there are several datagrid controls used to display, edit and delete
detail records relating to the master record also displayed on that
page. Each row in each datagrid includes a Delete button (added at
runtime by the code-behind page as a ButtonColumn) and an Edit button
(added at runtime by the code-behind page as an EditCommandColumn).
What is the quickest, easiest and most reliable way to add delete
confirmation functionality, so that when the user clicks the Delete
button, they must take some further action before the record is
actually deleted?

Thanks in advance for any help anyone can offer.

I'm operating under the following constraints:
1. This large application was written by a consultant, who did not
document his work, and who is no longer available for modifications
or bug corrections.
2. I'm a VB veteran but a relative newcomer to C# and the Dot Net
environment, a bit overwhelmed by it, and trying to get the job done
using the most straightforward & well-documented controls and
coding techniques.
3. All of our programmers (including those with substantial C#/Dot Net
experience) have had tremendous problems debugging the Java-script
code (both embedded in the C# source and generated by some of the
consultant's proprietary routines) this application relies on, and so
we're endeavoring to minimize its use as we correct and expand the
application.
4. In the _ItemCreated method for each datagrid, there is already some
Java-script specified for the "onclick" event, and so if implementing
delete confirmation requires adding more Java-script in the same
place, it will have to co-exist with the existing Java-script.
 
B

Betsuni

This is how I implemented a "Confirmation" on delete inside my
datagrid

HTML:
<asp:TemplateColumn headertext="Del" headerstyle-width="20">
<ItemTemplate>
<asp:ImageButton id="Delete" alternatetext="Delete"
commandname="Delete" onload="SetDeleteButton" runat="server"/>
</ItemTemplate>
</asp:TemplateColumn>

C#:
protected void SetDeleteButton(Object sender, EventArgs e) {
ImageButton ib = (ImageButton)sender;
//Set the graphic
SetButtonGraphics(ib, "icons/delete.gif", "", "");
//Set the javascript confirmation
ib.Attributes.Add("onclick", "return confirm('Confirm deletion of
record.');");
}





I'm working on an ASP.Net application written in C#. On one page,
there are several datagrid controls used to display, edit and delete
detail records relating to the master record also displayed on that
page. Each row in each datagrid includes a Delete button (added at
runtime by the code-behind page as a ButtonColumn) and an Edit button
(added at runtime by the code-behind page as an EditCommandColumn).
What is the quickest, easiest and most reliable way to add delete
confirmation functionality, so that when the user clicks the Delete
button, they must take some further action before the record is
actually deleted?

Thanks in advance for any help anyone can offer.

I'm operating under the following constraints:
1. This large application was written by a consultant, who did not
document his work, and who is no longer available for modifications
or bug corrections.
2. I'm a VB veteran but a relative newcomer to C# and the Dot Net
environment, a bit overwhelmed by it, and trying to get the job done
using the most straightforward & well-documented controls and
coding techniques.
3. All of our programmers (including those with substantial C#/Dot Net
experience) have had tremendous problems debugging the Java-script
code (both embedded in the C# source and generated by some of the
consultant's proprietary routines) this application relies on, and so
we're endeavoring to minimize its use as we correct and expand the
application.
4. In the _ItemCreated method for each datagrid, there is already some
Java-script specified for the "onclick" event, and so if implementing
delete confirmation requires adding more Java-script in the same
place, it will have to co-exist with the existing Java-script.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,982
Messages
2,570,186
Members
46,744
Latest member
CortneyMcK

Latest Threads

Top