Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Confirm delete of record

Reply
Thread Tools

Confirm delete of record

 
 
Iain
Guest
Posts: n/a
 
      01-23-2007
Hi All

I am witing a web app using Delphi developer 2006 (C# app) and I have a
datagrid. Excuse the numptyness of the question. I have a datagrid with
the ability to Insert, Edit/Update and Delete records.

The following is the datagrid definition

<asp:datagrid id="Livery"
runat="server"
allowsorting="True"
EnableViewState="true"
itemstyle-verticalalign="top"
headerstyle-font-bold="true"
headerstyle-forecolor="white"
headerstyle-backcolor="black"
autogeneratecolumns="false"
font-size="8pt"
cellpadding="5"
width="92%"
onsortcommand="Livery_SortCommand"
ondeletecommand="Livery_DeleteCommand"
oneditcommand="Livery_EditCommand"
onupdatecommand="Livery_UpdateCommand"
oncancelcommand="Livery_CancelCommand">
<EditItemStyle borderstyle="Dashed"
bordercolor="#0000C0"
backcolor="#FFFFC0">
</EditItemStyle>
<ItemStyle verticalalign="Top">
</ItemStyle>
<HeaderStyle font-bold="True"
forecolor="White"
backcolor="Black">
</HeaderStyle>
<Columns>
<ASP:EditCommandColumn buttontype="PushButton"
updatetext="Update"
headertext="Edit"
canceltext="Cancel"
edittext="Edit">
</ASP:EditCommandColumn>
<ASP:BoundColumn datafield="LIVNAME"
headertext="Livery Name">
</ASP:BoundColumn>
<ASP:BoundColumn datafield="LEADTIME"
headertext="Lead Time">
</ASP:BoundColumn>
<ASP:ButtonColumn text="Delete"
buttontype="PushButton"
headertext="Delete"
commandname="Delete">
</ASP:ButtonColumn>
</Columns>
</asp:datagrid>

The following is the Delete event which fires when I select the Delete
Button.


protected void Livery_DeleteCommand(object source,
System.Web.UI.WebControls.DataGridCommandEventArgs e)
{
..........
switch(e.Item.ItemType)
{
case ListItemType.Item:
case ListItemType.AlternatingItem:
{
Button btn = (Button)e.Item.Cells[0].Controls[0];
btn.Attributes.Add("onclick",
"return confirm('are you sure you want to delete this')");
break;
}
}
..........
Delete Record If Required
..........
}


This piece of code - I grabbed this off an example on the web - fires
but I am not sure that it is what I want. Do I understand this
correctly in that it is creating a button (called btn) and adding an
onclick event to it.
What I need is for the confirm to execute and return a value so that I
can confirm the deleting of the record selected.
Can anyone point me in the right direction ?

Thanks in advance for any help offered

Iain

 
Reply With Quote
 
 
 
 
Mark Rae
Guest
Posts: n/a
 
      01-23-2007
"Iain" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) ups.com...

> What I need is for the confirm to execute and return a value so that I
> can confirm the deleting of the record selected.


If the user clicks "Cancel", the delete event won't fire.


 
Reply With Quote
 
 
 
 
Iain
Guest
Posts: n/a
 
      01-23-2007
Hi Mark

Yes that is the cse.
However, I am a paranoid developer with a number of numpty's as users
and all I am trying to protect against is unneccessary deletion of
records and I just want the user to confirm that this is actually the
record they want to delete so I need this to fire and work

Thanks

Iain

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re:how i make a window confirm to delete at datagrid? Saravana ASP .Net 1 10-04-2004 03:27 PM
how i make a window confirm to delete at datagrid? Dexter ASP .Net 2 10-03-2004 10:43 PM
Confirm Delete popup from a LinkButton in a repeater Sandy ASP .Net 1 06-11-2004 05:37 PM
confirm('delete?') doesn't work on ie6 (windows xp) Spongebob ASP .Net 2 02-11-2004 09:38 PM
confirm box when clicking Delete Linkbutton in DG Calvin Lai ASP .Net 4 02-04-2004 03:03 PM



Advertisments