**急,求救,在线等!<未将对象引用设置到对象的实例>
一个数据库有a1,a2两个字段。
在使用SelectionList控件时,显示a1字段。当用户选择之后,
想通过一个按钮,把a2字段的对应值显示在下一个窗体中。
现在我用SelectionList1.Selection.Value;
当我设定Label1.text=SelectionList1.Selection.Value;时,调试出现<未将对象引用设置到对象的实例>的错误。
请高手指点,求救!
private void Command1_Click(object sender, System.EventArgs e)
{
Label1.Text=SelectionList1.Selection.Value; //此行报错。
this.ActiveForm=Form2;
}
private void Command1_Click(object sender, System.EventArgs e)
{
if (SelectionList1.Selection.Value!="") {
Label1.Text=SelectionList1.Selection.Value;
this.ActiveForm=Form2;
}
}
另外要看你的页面上有没有Label1控件?
各位,以上的方法我都试了,可还是不行。
private void Command1_Click(object sender, System.EventArgs e)
{
if (SelectionList1.Selection.Value!="") //连这行都过不去。
{
Label1.Text=SelectionList1.Selection.Value;
this.ActiveForm=Form2;
}
}