.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Sandeep Singh
Melody Anderson
Eminent IT

Home >> Forum >> ASP.Net >> Post New QuestionBookmark and Share Subscribe to Forum

Alert messgae in popup in GridView while edit

Posted By: Ramesh     Posted Date: July 30, 2010    Points:2   Category :ASP.Net

can i pop up an alert message on the edit button of the Gridview and how can i do it in asp.net?


Author: Sunil Yadav       [Moderator]      
Posted Date: July 30, 2010     Points: 5   


You can use the below code for edit confirmation.

1. Add a command argument on delete button.
<asp:GridView ID="GridView1" runat="server" DataKeyNames="Host" AllowPaging="True"
AutoGenerateColumns="False" OnRowCommand="GridView1_RowCommand" OnRowDataBound="GridView1_RowDataBound">

<asp:LinkButton ID="lnkEdit" CommandName="Edit" runat="server" Text="Edit"></asp:LinkButton>

2. Add a attribute on GridView1_RowDataBound event to LinkButton lnkDelete.

  protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
if (e.Row.RowType == DataControlRowType.DataRow)

LinkButton lnkEdit= (LinkButton)e.Row.FindControl("lnkEdit");

lnkEdit.Attributes.Add("onclick", "javascript:return " +
"confirm('Are you sure you want to update record for this " +
DataBinder.Eval(e.Row.DataItem, "Host") + "')");


3. Now perform a delete operation on GridView1_RowCommand event. You can also do it on GridView1_Editing event.

 protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
GridView gv = (GridView)sender;

if (e.CommandName == "Edit")

// Update record here...........

hope it helps.

Post Reply

You must Sign In To post reply
Find more Forum Questions on C#, ASP.Net, Vb.Net, SQL Server and more Here
Quick Links For Forum Categories:
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  OOPs  SilverlightIISJQuery

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend