In one group on the page there are 2 switches:
<asp:RadioButton ID="RadioButton1" runat="server" GroupName="Group1"/> <asp:RadioButton ID="RadioButton2" runat="server" GroupName="Group1"/>
In code, I wrote code to test both switches:
RadioButton1.Checked = true; RadioButton2.Checked = true;
I thought that RadioButton1.Checked would be false , because they are in the same group, when I check the second, the first will automatically disconnect. But in fact they are both Checked=true .
In my application there is such a switch case:
// Some code to check the default RadioButton switch(val){ case 1: RadioButton1.Checked = true; case 2: RadioButton2.Checked = true; }
Therefore, sometimes both Checked switches will be true. This is strange, so I changed the code to:
switch(val){ case 1: RadioButton1.Checked = true; RadioButton2.Checked = false; case 2: RadioButton1.Checked = false; RadioButton2.Checked = true; }
This works fine, but what if I need to add 10 more radio buttons, write a long list = true, = false .....?
Any ideas? Thanks!
source share