DropDownList.SelectedValue 选定值
ddlState.SelectedItem.Text 当前文本
就应该用这个语句的
DropDownList.selectedItem.value
至于你获得的值不对,是因为你没有把DropDownList的AutoPostBack属性设为true。
protected void Button1_Click(object sender, EventArgs e)
{
string s1 = DropDownList1.SelectedItem.Text;
string s2 = DropDownList2.SelectedItem.Text;
string s3 = DropDownList3.SelectedItem.Text;
string s4 = DropDownList4.SelectedItem.Text;
Response.Write(s1 + s2 + s3 + s4);
}
没有任何问题
combox吧是 你把它设为dropdownlist风格吧是?
获取combox的文本和后台值如下
this.combox.selectItem.tostring
this.combox.valueMenber//前提是你得绑了后台值
两种解决办法,一个是可以把DropDownList的AutoPostBack属性设置为true; 另一个办法是用javascript实时获取选定的项目