i want to show an alert box while deleting record from the gridview control.how can i do that.
Loading
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Pradeep ShetRank #595 · 4K reputationPosted Feb 8, 2015, 10:18 AM EST
If you going for server side delete which will include your postback then you can register the script by adding the below code once your delete code is executed
ClientScript.RegisterStartupScript(this.GetType(),"key", "javascript:alert(deleted successfully');", true);
https://msdn.microsoft.com/en-us/library/system.web.ui.clientscriptmanager.registerstartupscript%28v=vs.110%29.aspx
Hope you will get it and solves your problem. Plz mark it as answered if it really helped you.
Joginder BangerRank #360 · 7K reputationPosted Feb 8, 2015, 10:14 AM EST
Umair,
alert message popup only have two condition one is before the data delete and another one is after the delete data.which you want?
Khargesh RajputRank #616 · 3.9K reputationPosted Feb 8, 2015, 6:15 PM EST
USe
butteon inside item template
and on gridview rowdatabound do that
if (e.Row.RowType == DataControlRowType.DataRow)
{
LinkButton lnkDelete;
lnkDelete = (LinkButton)e.Row.FindControl("lnkDelete");
lnkDelete.Attributes.Add("onclick", "javascript:if(confirm('Are you sure you want to delete?'))return true; else return false;");
}
umair mohsinRank #3,092 · 463 reputationPosted Feb 8, 2015, 7:36 PM EST
umair mohsinRank #3,092 · 463 reputationPosted Feb 8, 2015, 7:43 PM EST
umair mohsinRank #3,092 · 463 reputationPosted Feb 8, 2015, 8:09 PM EST
Khargesh RajputRank #616 · 3.9K reputationPosted Feb 8, 2015, 10:08 PM EST
and call javascript by code behind on row data bound or by clientside
Pradeep ShetRank #595 · 4K reputationPosted Feb 12, 2015, 3:16 AM EST
Row deleting or row_updating event gets triggered when you click on button at row level.
And Rowdatabound event is triggered when all the data is bound to grid one by one. Rowdatabound is used for doing any modification to data or control while each row of data is bound.
Both are for different purpose so dont get confused.