如何防止添加兩個控件或列表?我試過這段代碼,但它不起作用... Pease help!如何防止在asp.net中添加兩個列表?
protected void Page_Load(object sender, EventArgs e)
{
if (!this.IsPostBack)
{
ViewState["check"] = "First_Time";
}
}
protected void Button1_Click(object sender, EventArgs e)
{
if (ViewState["check"] == "First_Time")
{
for (int i = 0; i < 6; i++)
{
CheckBoxList1.Items.Add(i.ToString());
}
ViewState["check"] = "Scond_Time";
}
else
{
Response.Write("Sorry, Can't create a list on second time");
}
}
請問您能否澄清您所問的內容?現在有點不清楚。 「防止添加兩個控件或列表」是什麼意思?你確定你正確使用'to'和'two'嗎? –
你有做ViewState檢查的原因嗎? – logixologist