获取RadioButton的text值的问题
datalist中的模版列用到了RadioButton,而且是有几个不同组别的RadioButton(由于编程原因,必须用RadioButton,不能用html的radio),把记录的id绑定到RadioButton的text属性,在datalist外面(注意是在datalist外面)有一个button,单击button要获取到这些不同组别中的被选中的RadioButton的text值,请问怎么做到?请尽量提供代码,谢谢!!!最好是vb.net的哦..
[解决办法]
通过datalist的结构来循环.如表格的行,然后循环radiobutton的table
[解决办法]
不熟悉 VB
<asp:DataList ID= "DataList1 " runat= "server ">
<ItemTemplate>
<asp:RadioButton ID= "RadioButton1 " runat= "server " />
</ItemTemplate>
</asp:DataList>
<asp:Button ID= "Button1 " runat= "server " OnClick= "Button1_Click " />
void Button1_Click(object sender, EventArgs e)
{
foreach (DataListItem item in DataList1.Items) {
RadioButton radioButton1 = item.FindControl( "radioButton1 ") as RadioButton;
if (radioButton1 != null) {
if (radioButton1.Checked) {
string str = radioButton1.Text;
// more codes
}
}
}
}