
写到SelectedIndexChanged事件里面
要先把dropdownlist控灶乎件的autopostback属性改为true
private void DropDownList1_SelectedIndexChanged(object sender, System.EventArgs e)
{
this.Label3.Text=this.DropDownList2.SelectedItem.ToString();//text this.Label4.Text=this.DropDownList2.SelectedValue.ToString();//携粗value
}
如果用按钮就可以直接隐隐悉写
private void Button1_Click(object sender, System.EventArgs e)
{
this.Label1.Text=this.DropDownList1.SelectedItem.ToString();
this.Label2.Text=this.DropDownList1.SelectedValue.ToString();
}
//WebForm
dl.SelectedItem.Text //这个是选哪衡中的文字
dl.SelectedItem.Value //这个是选中文字的配缓兄Value值培袭
遍历元素后 判断 selectd