如何可以调用一个变量(私有标签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 !!