Register
|
Articles
|
Questions
|
Projects
|
Asp.Net Tips
|
Free Magazines
|
Tutorials
|
Search
|
Write to us
|
Login
Search
Articles
Asp.Net 2.0
AJAX
ADO.Net
C#
Javascript
Books
Asp.Net 2.0
AJAX
ADO.NET
C#
JavaScript
MS SQL Server
SilverLight
VB.NET
XML
Web Service
Resources
Asp.Net News
Downloads
Free Tech Magazines
Asp.Net Web Hosting
Archives
Softwares
Newsletter
Suggest Us
Link to Us
Feeds Subscription
Articles
Questions & Answers
Tips & Tricks
How To Add JavaScript Delete Confirmation in GridView "Delete" Command Button dynamically?
Posted by
Moderator1
on
2/13/2009 3:27:44 AM
6352
Views
In the RowDataBound event of the GridView control, find the Delete Command Button control by specifying the cell index. Then add an attribute to that control has follows.
if (e.Row.RowType == DataControlRowType.DataRow)
{
if (e.Row.Cells[1].HasControls())
{
LinkButton lnkbtnDelete = ((LinkButton)e.Row.Cells[1].Controls[0]);
lnkbtnDelete.Attributes.Add("onclick", "return confirm('Do you want to Delete?');");
}
}
Note:
1. The Cell starts with 0 Index.
2. The line "if (e.Row.Cells[1].HasControls())" is to check, if the control is exists or not. This will be useful, when Edit Command Button is used along with Delete Command Button.
Post New Tips/Tricks
View all Tips/Tricks
Featured Resources:
The Beginner's Guide to Joomla
An Introduction to an Award-Winning Content Management System (CMS).
When Good HTML Goes Bad: How You Can Protect Your Web Applications
This webinar highlights how modern attacks target the web browser – and the best practices to safeguard your web applications against these risks.
100% Free Subscription until Stock lost.
View complete list.
Sponsored by
Home
About us
Contact Us
Links
Advertise
Privacy Policy
Copyright ©
2012
. www.AspdotnetCodes.com. All rights reserved.