【发布时间】:2011-05-21 07:14:37
【问题描述】:
我有 30 个单独的 RadioButton。我不能使用 RadioButtonList。有 3 组按钮。每个组都有一个唯一的 GroupName。一切都在网络浏览器中正常工作。我如何在回帖中知道在每个给定的 GroupsNames 中选择了哪个按钮?
编辑:我使用的功能
private string getRadioValue(ControlCollection clts, string groupName)
{
string ret = "";
foreach (Control ctl in clts)
{
if (ctl.Controls.Count != 0)
{
if (ret == "")
ret = getRadioValue(ctl.Controls, groupName);
}
if (ctl.ToString() == "System.Web.UI.WebControls.RadioButton")
{
RadioButton rb = (RadioButton)ctl;
if (rb.GroupName == groupName && rb.Checked == true)
ret = rb.Attributes["Value"];
}
}
return ret;
}
【问题讨论】:
标签: c# asp.net radio-button