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.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Pradeep ShetPosted Feb 8, 2015, 3:18 PM
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.
Pradeep ShetPosted Feb 12, 2015, 8:16 AM
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.
Khargesh RajputPosted Feb 9, 2015, 3:08 AM
and call javascript by code behind on row data bound or by clientside
umair mohsinPosted Feb 9, 2015, 1:09 AM
umair mohsinPosted Feb 9, 2015, 12:43 AM
umair mohsinPosted Feb 9, 2015, 12:36 AM
Khargesh RajputPosted Feb 8, 2015, 11:15 PM
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;");
}
Joginder BangerPosted Feb 8, 2015, 3:14 PM
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?