編集
要件については 、 RequiredFieldValidatorを使用してRadioButtonListを使用することをお勧めします。以下は例です
<asp:RadioButtonList
ID="RadioButtonList1"
runat="server"
RepeatColumns="3">
<asp:ListItem>abcd</asp:ListItem>
<asp:ListItem>xyz</asp:ListItem>
</asp:RadioButtonList>
<asp:RequiredFieldValidator
ID="ReqiredFieldValidator1"
runat="server"
ControlToValidate="RadioButtonList1"
ErrorMessage="select atleast one radiobutton!">*
</asp:RequiredFieldValidator>
ラジオ ボタンをグループ化する必要がありますGroupName="foo"は、2 つのラジオ ボタンが存在するグループであるため、一度に 1 つだけが選択されます。
<asp:panel runa="server" id="container">
<asp:RadioButton id="Radio1" GroupName="foo"
Text="Beef" BackColor="Pink" runat="server"/>
<br />
<asp:RadioButton id="Radio2" GroupName="foo"
Text="Pork" BackColor="Pink" runat="server"/>
</asp:panel>
HTMLでも、ラジオボタンのグループから1つを選択するには、ラジオボタンのグループ名を指定する必要があることに注意してください
比率ボタンが選択されているかどうかを確認するには、このlinq操作を使用するだけではありません
bool isradchecked=container.Controls.OfType<RadioButton>)
.Any(r => r.Checked);
こちらラジオボタンの入れ物はAsp:Panel
.