c#获取一组DropDownList的选中项Value和Text的值

2025-03-02 00:53:50
推荐回答(5个)
回答1:

DropDownList.SelectedValue 选定值
ddlState.SelectedItem.Text 当前文本

回答2:

就应该用这个语句的
DropDownList.selectedItem.value
至于你获得的值不对,是因为你没有把DropDownList的AutoPostBack属性设为true。

回答3:

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);
}

没有任何问题

回答4:

combox吧是 你把它设为dropdownlist风格吧是?
获取combox的文本和后台值如下
this.combox.selectItem.tostring
this.combox.valueMenber//前提是你得绑了后台值

回答5:

两种解决办法,一个是可以把DropDownList的AutoPostBack属性设置为true; 另一个办法是用javascript实时获取选定的项目