用户刷新页面时如何清除标签的值

用户刷新页面时如何清除标签的值

本文介绍了用户刷新页面时如何清除标签的值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

protected void Button1_Click(object sender, EventArgs e)
    {
       

            foreach (RepeaterItem item2 in Repeater1.Items)
            {

                CheckBox chkdel = item2.FindControl("CheckBox1") as CheckBox;
                if (chkdel.Checked)
                {


                    int lblid = Convert.ToInt32((item2.FindControl("Label1") as Label).Text);
                    string SqlConnect = System.Configuration.ConfigurationManager.ConnectionStrings["Connect"].ConnectionString;
                    SqlConnection Sqlconn = new SqlConnection(SqlConnect);
                    SqlCommand Sqlcomm = new SqlCommand("Delstock", Sqlconn);
                    Sqlcomm.CommandType = CommandType.StoredProcedure;
                    Sqlconn.Open();
                    Sqlcomm.Parameters.Add("@id", SqlDbType.Int).Value = lblid;
                    Sqlcomm.ExecuteNonQuery();
                    Sqlconn.Close();
                    Label2.Visible = true;

                    Label2.Text = "Stock Detail(s) Deleted";

                }


            }
            BindStockDetails();
       
   
    }




推荐答案

Label2.Text = "";



<asp:Label ID="lblMsg" runat="server" Text="Stock Detail(s) Deleted" EnableViewState="false" visible="false"></asp:Label>


这就是您要寻找的.请注意


This is what you are looking for. Please Note

EnableViewState="false"



dheeraj9457已经提到了这一点.我只是觉得应该澄清一下.

希望对您有所帮助.



dheeraj9457 has already mentioned this.I just felt i should clarify.

Hope it helps.


这篇关于用户刷新页面时如何清除标签的值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-21 20:02