内にラジオボタンdatagridがありますrepeater。radiobuttons内の「リピート」ごとに4つ作成されてrepeaterおり、これら4つのうち1つを選択する必要があります。すでにradiobuttons同じものGroupNameに入れているので、1つしか選べません。
それらはラジオボタンリストに含まれておらず、ラジオボタンリストに入れたくありません。
内にラジオボタンdatagridがありますrepeater。radiobuttons内の「リピート」ごとに4つ作成されてrepeaterおり、これら4つのうち1つを選択する必要があります。すでにradiobuttons同じものGroupNameに入れているので、1つしか選べません。
それらはラジオボタンリストに含まれておらず、ラジオボタンリストに入れたくありません。
同じグループ名でそれらを持っているので、カスタムバリデーターを作ることができます。
<asp:CustomValidator ID="myValidator" runat="server" ErrorMessage="you must select one" onservervalidate="myValidator_serverValidate" />
次に、背後のコードで、
protected void myValidator_serverValidate(object sender, ServerValidateEventArgs e)
{
bool isSelected = false;
foreach (Control control in yourForm.Controls)
{
if (control == RadioButton)
{
RadioButton rb = (RadioButton)control;
if (rb.GroupName == "myGroup" && rb.Checked)
{
isSelected = true;
}
}
}
e.IsValid = isSelected;
}