From the below thread Reference
how to use asp:Boundfield in gridview for deleting records
You need to use setTimeout function of JavaScript
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<script type="text/javascript">
function AllRecordDeleted() {
setTimeout(function () {
$("#MainMessagesPanel").fadeOut("slow");
}, 2000);
}
</script>
Add this HTML below Delete Button
<asp:Panel runat="server" ID="MainMessagesPanel" Visible="false">
All Records Deleted
</asp:Panel>
C#
Delete Button Event
protected void DeleteAll(object sender, EventArgs e)
{
MainMessagesPanel.Visible = true;
foreach (GridViewRow row in this.GridView1.Rows)
{
int id = Convert.ToInt32(this.GridView1.DataKeys[row.RowIndex].Value);
}
ClientScript.RegisterStartupScript(this.GetType(), "alert", "AllRecordDeleted();", true);
}
DEMO
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<script type="text/javascript">
function AllRecordDeleted() {
setTimeout(function () {
$("[id*=MainMessagesPanel]").fadeOut("slow");
}, 2000);
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<input type="button" name="name" onclick="AllRecordDeleted()" value="Delete All" />
<div id="MainMessagesPanel">
All Records Deleted
</div>
</div>
</form>
</body>
</html>
Demo