C# 动态添加单选按钮后,如何检查选定的单选按钮

C# 动态添加单选按钮后,如何检查选定的单选按钮,c#,asp.net,radio-button,C#,Asp.net,Radio Button,我动态添加了如下单选按钮: foreach(DataRow row in results.Rows) { RadioButton radioButton = new RadioButton(); radioButton.ID = "reason_" + row["reasonName"].ToString(); radioButton.GroupName = "reason"; radioButton.Text = row["reasonName"].ToStri

我动态添加了如下单选按钮:

foreach(DataRow row in results.Rows) {
    RadioButton radioButton = new RadioButton();
    radioButton.ID = "reason_" + row["reasonName"].ToString();
    radioButton.GroupName = "reason";
    radioButton.Text = row["reasonName"].ToString();
    div.Controls.Add(radioButton);
    myValueDiv.Controls.Add(div);
}

我的页面上有一个按钮。如何知道用户单击哪个单选按钮时选中了它?

正如我在评论中提到的,这应该会有所帮助

var checkedRadioButtons = myValueDiv.Controls.OfType<RadioButton>().Where(radButton => radButton.Checked);

遍历myValueDiv的所有无线电控件并简单地检查选择了哪一个怎么样。可以使用Linq查询在一行中完成。