The ASPX-page contains a Repeater control defined as follows:
<asp:Repeater ID="answerVariantRepeater" runat="server"
onitemdatabound="answerVariantRepeater_ItemDataBound">
<ItemTemplate>
<asp:RadioButton ID="answerVariantRadioButton" runat="server"
GroupName="answerVariants"
Text='<%# DataBinder.Eval(Container.DataItem, "Text")%>'"/>
</ItemTemplate>
</asp:Repeater>
To ensure that only one radio button can be selected at a time, a solution from this article was implemented.
Now, upon form submission, there is a need to determine which radio button has been checked.
One way to achieve this is through the following code snippet:
RadioButton checkedButton = null;
foreach (RepeaterItem item in answerVariantRepeater.Items)
{
RadioButton control=(RadioButton)item.FindControl("answerVariantRadioButton");
if (control.Checked)
{
checkedButton = control;
break;
}
}
However, there might be a simpler approach, possibly utilizing LINQ to objects.