問題是,每次我做一個回發我的變量「值」不保留它的以前的值,並且總是字典是空的。它沒有任何以前保存的數據。我怎樣才能保存數據?全局變量不保留其值
這是代碼:
public partial class MyCart : System.Web.UI.Page
{
public Dictionary<string, string> value = new Dictionary<string, string>();
protected void Page_Load(object sender, EventArgs e)
{
TextBox textbox = new TextBox();
textbox.TextChanged += textbox_TextChanged;
textbox.ID = "textbox" + p.IDProduct.ToString();
Button button = new Button();
}
void textbox_TextChanged(object sender, EventArgs e)
{
value.Add(((TextBox)sender).ID, ((TextBox)sender).Text);
}
}
好的,我明白了。謝謝 ! –
歡迎您 – Adil
感謝Adil Bhai ..它幫助了我很多 – kashif