我已经将某数据表的所有列名添加到了DropDownList中了,但是如何将选定的值赋给Label呢。
private void DropDownList1_SelectedIndexChanged(object sender, System.EventArgs e)
{
Label1.Text = DropDownList1.SelectedItem.Value;
}这样为什么不可以阿,请指教。
谢谢!

解决方案 »

  1.   

    Label1.Text = DropDownList1.SelectedItem.Text;
      

  2.   

    你将DropDownList的AutoPostBack设为True就可以了
      

  3.   

    AutoPostBack=TRUE
    你要设定事件才能触发啊~选择改变后label1的文本绑定才可以
      

  4.   

    Label1.Text = DropDownList1.SelectedItem.Text;
    Label1.Text = DropDownList1.SelectedItem.Value;
    Label1.Text = DropDownList1.SelectedValue;
      

  5.   

    结帖吧
    要想 DropDownList1_SelectedIndexChanged 事件发生
    需要将 DropDownList1的AutoPostBack=TRUE用Label1.Text = DropDownList1.SelectedItem.Text;
    或者
    Label1.Text = DropDownList1.SelectedItem.Value;
    过此时 value 属性得有值哦
      

  6.   

    Label1.Text = DropDownList1.SelectedValue;
      

  7.   

    Label1.Text = DropDownList1.SelectedValue;
    DropDownList1.AutoPostBack要设为true
      

  8.   

    dropdownlist1.selectitem.value...是值
    dropdownlist1.selectitem.text....是文本dropdownlist1.items.add(new listitem("文本","值"))