Add a hidden variable to the page, and by default set it to "N".
<asp:hiddenfield id="DisplayedAlready" runat="server" value="N" xmlns:asp="#unknown" />
and inside
protected void Button1_Click(object sender, EventArgs e)
{
try
{
.......
con.Close();
if (DisplayedAlready.Value == "N")
{
DisplayedAlready.Value == "Y";
Label2.Visible = true;
Label2.Text = "Data has Been Successfully inserted";
}
else
{
Label2.Text = string.Empty;
}
......
}
catch (Exception es)
{
DisplayedAlready.Value = "N";
}
}
Also remember to reset the value of DisplayedAlready value to "N" if there is any reset case.
See if this works for you.