内にラジオボタン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;
}