充分利用单选按钮列表中选择价值 [英] Getting selected value from RadioButtonList
本文介绍了充分利用单选按钮列表中选择价值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
新的ASP.NET(C#)...
New to ASP.NET(C#)...
我有我的网页上一个单选按钮列表,它通过数据绑定填充
I have a RadioButtonList on my page that is populated via DataBinding
<asp:RadioButtonList ID="rb" runat="server">
</asp:RadioButtonList>
<asp:Button Text="Submit" OnClick="submit" runat="server" />
我如何获取用户在我的提交方法选择的单选按钮的价值?
How do I get the value of the radio button that the user selected in my "submit" method?
推荐答案
在ASPX code会是这个样子:
The ASPX code will look something like this:
<asp:RadioButtonList ID="rblist1" runat="server">
<asp:ListItem Text ="Item1" Value="1" />
<asp:ListItem Text ="Item2" Value="2" />
<asp:ListItem Text ="Item3" Value="3" />
<asp:ListItem Text ="Item4" Value="4" />
</asp:RadioButtonList>
<asp:Button ID="btn1" runat="server" OnClick="Button1_Click" Text="select value" />
和背后的code:
protected void Button1_Click(object sender, EventArgs e)
{
string selectedValue = rblist1.SelectedValue;
Response.Write(selectedValue);
}
这篇关于充分利用单选按钮列表中选择价值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文