如何可以調用一個變量(私有標籤CCC;)調用varialble在另一個事件:從另一事件
private Label ccc;
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{
Label Label1 = FindControlRecursive(Page, DropDownList1.SelectedValue) as Label;
if (Label1 != null)
this.ccc = lblCont;
this.ccc.Text = Label1.Text;
}
public void btnSubmit_Click(object sender, EventArgs e)
{
try
{
this.ccc.Text = lblCont.Text;
int bbb = Convert.ToInt32(lblCont.Text) - Convert.ToInt32(tbEnter.Text);
if (bbb >= 0)
{
lblCont.Text = Convert.ToString(bbb);
}
else
{
ErrorDisplay.Text = "There are not enough tickets";
}
}
catch (Exception ex)
{
ErrorDisplay.Text = ex.Message;
}
}
我不能叫this.ccc.Text = lblCont.Text;在 「公共無效btnSubmit_Clic K」
它(對象引用不設置爲一個對象的一個實例。)
Thakns !!