Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Datagrid Control > Alert to confirm deletes in the new GridView control

Reply
Thread Tools

Alert to confirm deletes in the new GridView control

 
 
dev648237923
Guest
Posts: n/a
 
      11-17-2006
I want to have an alert to confirm deletes in the GridView. I have seen
posting for doing it in DataGrid but I can not get it to work in the new
GridView. I tried in GridView1_RowCommand I tried something like:

((LinkButton)GridView1.SelectedRow.FindControl("lb Delete")).Attributes.Add(
"onClick", "return confirm('Are you sure you want to delete this row?');");

Any ideas would be appretiated!

Thank you!





 
Reply With Quote
 
 
 
 
Steven Cheng[MSFT]
Guest
Posts: n/a
 
      11-20-2006
Hi dev648237923,

If you're using TemplateField, it is convenient for us to customize the
controls in the template. The code project article you mentioend use
"RowDataBound" event to add the "confirm delete" javascript for the
delete button. You can also do it through the "RowCreated" event.

In addition, in ASP.NET 2.0, button or LinkButton control provide the
"OnClientClick" property that can let you add client-side click script.
Therefore, you can also add the "confirm deleting" script in the LinkButton
or Button's "OnClientClick" property. e.g


=========================
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"
DataKeyNames="CategoryID"
DataSourceID="SqlDataSource1">
<Columns>
<asp:TemplateField ShowHeader="False">
..............
<ItemTemplate>
.............................
<asp:LinkButton ID="LinkButton2" runat="server"

OnClientClick="if(confirm('Are you sure to
delete this item?') == false){return false;}"

CausesValidation="False" CommandName="Delete"
Text="Delete"></asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
==============================

Hope this also helps.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead



==================================================

Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.



Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.

==================================================



This posting is provided "AS IS" with no warranties, and confers no rights.

 
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
Alert..General Alert?..New Discovery?. =?Utf-8?B?U3BhbW1lcipLaWxsZXI=?= Wireless Networking 0 07-24-2007 03:36 PM
Multiple Deletes in Gridview MasterChief ASP .Net 4 02-07-2006 05:56 PM
Need to cancel a javascript alert/confirm box Tasha's Dad Javascript 5 11-09-2004 01:54 PM
overloaded global operator new/new[] and corresponding deletes question Dodo C++ 1 08-26-2003 01:59 PM
alert() and confirm() function Andy Fish Javascript 7 08-14-2003 03:21 PM



Advertisments