473,387 Members | 1,456 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Delete confirmation

How can I add the confirmation dialog on record delete to the "Delete"
command column in DataGrid control?
Nov 18 '05 #1
3 1733
Here is a sample:
http://www.dotnetjunkies.com/HowTo/1...EB07C94A8.dcik

"Dave" <da*********@hotmail.com> wrote in message
news:uv*************@tk2msftngp13.phx.gbl...
How can I add the confirmation dialog on record delete to the "Delete"
command column in DataGrid control?

Nov 18 '05 #2
To JavaScript Prompts for Buttons in Asp::DataGrid for Delete Column

http://www.akashkava.com/articles/as...t-prompts.html

"Dave" <da*********@hotmail.com> wrote in message
news:uv*************@tk2msftngp13.phx.gbl...
How can I add the confirmation dialog on record delete to the "Delete"
command column in DataGrid control?


Nov 18 '05 #3
Something like this should do the trick for you.

<code>
Private Sub TheGrid_ItemDataBound(ByVal sender As System.Object, ByVal e As
System.Web.UI.WebControls.DataGridItemEventArgs) Handles
TheGrid.ItemDataBound
Try
Select Case e.Item.ItemType
Case ListItemType.Item, ListItemType.AlternatingItem,
ListItemType.EditItem, ListItemType.SelectedItem
' change this value to the column value to match that of your datagrid's
column containing the delete linkbutton
Dim intYourCellThatHasTheDeleteLinkButton = 0
Dim lb as LinkButton =
GetLinkButton(e.Item.Cells(intYourCellThatHasTheDe leteLinkButton))
If Not lb Is Nothing Then
' add an onclick attribute that will prompt the user
' if the user selects ok, then the DeleteCommand event will fire.
' if the user selects cancel, then it will not
lb.Addributes.Add("onclick", "return confirm(""Are you sure you want to
delete this record?"");")
End If
End Select

Catch ex As Exception
' Your error handler here
End Try
End Sub

Function GetLinkButton(Cell as TableCell) as LinkButton
For Each ctl As Control In Cell.Controls
If TypeOf(ctl) Is LinkButton Then
Return DirectCast(ctl, LinkButton)
End If
Next
End Function
</code>

HTH
Craig

"Dave" <da*********@hotmail.com> wrote in message
news:uv*************@tk2msftngp13.phx.gbl...
How can I add the confirmation dialog on record delete to the "Delete"
command column in DataGrid control?

Nov 18 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Les Juby | last post by:
I've used a simple javascript for some time (no entries required up in the <head> tag) that asks for a confirmation before deleting. ie. <a href="/delete.asp?which=345 %>"...
4
by: Stephen | last post by:
Hello People, Using MS Access 2003 VBA I get the error 3020 Update or CancelUpdate without AddNew or Edit when I run through the following code. Can anyone help suggest anything to try? Thanks....
6
by: Dotnet Guy | last post by:
I want to add a confirmation dialog box before I delete the records in my form. I have a piece of javascript code in html that checks for confirmation. But the main issue lies in calling this...
3
by: vcornjamb | last post by:
Hello, I am developing a web form that contains some buttons and a data grid which has as its last column link buttons that will delete the data associated with that row. Everything works fine,...
4
by: DrData | last post by:
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...
0
by: Elton W | last post by:
Hi Peter, You use DeleteButton.Attributes.Add("onclick", "return confirm ('Are you sure you want to delete?');"); in datagrid_ItemDataBound event to add confirmation for delete button.
0
by: Suzanne | last post by:
I'd like to know how can I put up a confirmation question when the user tries to delete a row in the datagrid by clicking on the row header and pressing the Delete key? I have found this code on...
17
by: (PeteCresswell) | last post by:
I've got apps where you *really* wouldn't want to delete certain items by accident, but the users just have to have a "Delete" button. My current strategies: Plan A:...
0
by: johnmott | last post by:
Hi all, One of the limitations of the GridView control is that the built-in delete processing doesn't prompt for confirmation -- something thats very important for a user interface. True, you...
0
by: Eraser | last post by:
Hi to all .NET guru guys... I have a problem in my delete button inside gridview. How to avoid postback on when i select cancel on confirmation message? But postback is okay on Ok confirmation....
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.