单击 button怎样获取radiobuttonlist的值?

来源:百度知道 编辑:UC知道 时间:2024/05/28 20:06:01
单击 button怎样获取radiobuttonlist的值?
但是我想通过赋值的方式,让ui上面先择一个我想的表示选中!

string val=this.RadioButtonList1.SelectedValue;
//val就是当前选中项的值

--------------------

你能说清楚一点儿吧..?

你是想根据某个值.来改变某一项被选中?

如果是这样儿的话.我刚已经答过你一次了.循环它:

for(int ii=0;ii<this.RadioButtonList1.Items.Count;ii++){
if(this.RadioButtonList1.Items[ii].Value.Equals("你想选中项的值")){
this.RadioButtonList1.Items[ii].Selected=true;
break;
}
}

string value = Request.QueryString["value"];
//我假设你的url参数是?value=xxx
this.RadioButtonList1.SelectValue = value;
//这就可以了
RadioButtonList对SelectValue属性的解释:
Gets the value of the selected item in the list control, or selects the item in the list control that contains the specified value.

this.RadioButtonList1.SelectedValue获取你选中项的value值