C# Tutorials and offshore development in India
Tutorials Resources Forum Reviews Communities Interview Jobs Projects Training Videos


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...


Birthday Greetings
Learn Windows 7: How to change the performance of background programs in Windows XP   This article will tell you about How to change the performance of background programs in Windows XP.



Resources » Code Snippets » ASP.NET GridView »

Adding Javascript Alert for Delete button in Gridview


Posted Date: 28 Nov 2008    Resource Type: Code Snippets    Category: ASP.NET GridView
Author: narenderraobalguriMember Level: Silver    
Rating: 1 out of 5Points: 5



hi all,
to give a alert before deleting a recored form gridview u can use this code.
First u place a linkbutton in gridview colums as shown below.
COde:
AutoGenerateColumns="False" Width="100%" OnRowEditing="gvdemo_RowEditing" DataKeyNames="bigint_DemoId" OnRowDataBound="gvdemo_RowDataBound" OnRowCommand="gvdemo_RowCommand">


























Delete









COde For DElete link Button separately:


Delete




COde To Add ALert :
For this we use Grid view Row bound event
code:
protected void gvdemo_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
Button imgdelete = (Button)e.Row.FindControl("imgdelete");//Find the button
imgdelete.Attributes.Add("onclick", "javascript:return " +
"confirm('Are you sure you want to delete " +
DataBinder.Eval(e.Row.DataItem, "var_DemoDate") + " " +
DataBinder.Eval(e.Row.DataItem, "var_DemoTime") + "')");// alert adding
}
}


Happy coding...






Responses to the resource: "Adding Javascript Alert for Delete button in Gridview"

No responses found. Be the first to respond and make money from revenue sharing program.

Feedbacks      
Popular Tags   What are tags ?   Search Tags  
Sign In to add tags.
ALert  .  Delete Alert  .  

Post Feedback


This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must Sign In to post a response.
Next Resource: using Gridview RowCommand Event
Previous Resource: Gridview Item template
Return to Resources
Post New Resource
Category: ASP.NET GridView


Post resources and earn money!
 
More Resources



About Us    Contact Us    Privacy Policy    Terms Of Use