How to control a RadioButtonList via code

1

I'm using C # asp.net web forms

I have two RadioButtonList

<asp:RadioButtonList ID="rblGrupo" runat="server" AutoPostBack="True" CellPadding="5" OnSelectedIndexChanged="rblGrupo_SelectedIndexChanged">
                                            <asp:ListItem Selected="True">Geral</asp:ListItem>
                                            <asp:ListItem>Por Grupo</asp:ListItem>
                                        </asp:RadioButtonList>

<asp:RadioButtonList Enabled="false" ID="rblSubGrupo" runat="server" AutoPostBack="True" CellPadding="5" OnSelectedIndexChanged="rblSubGrupo_SelectedIndexChanged">
                                                <asp:ListItem Selected="True">Geral</asp:ListItem>
                                                <asp:ListItem>Por Sub-Grupo</asp:ListItem>
                                            </asp:RadioButtonList>

One with Geral and Por Grupo and the other with Geral and Por SubGrupo

I wanted that when the Geral of the Group was selected, automatically the Geral of the Sub Group was also selected.

Assuming that the person first chose a group and a subgroup, but then he wants only one group, in that situation I would like the Sub Group to be marked as Geral

    
asked by anonymous 15.10.2015 / 20:58

1 answer

1

Something like this:

if(Grupo.Checked){
 SubGrupo.Checked = true
else
 SubGrupo.Checked = false;
}

Or so:

boolean radio;  
radio =  radiobutton.isSelected(); 

here you check:

if(radio == true) { //selecionado }  
else { //nullo }  

See if it solves your problem

I saw that you use the RadioButtonList, so it would look something like this:

if(RadioGrupo.SelectedIndex == 0){
 radiosubgrupo.selectedindex = 0
else
....
}
    
15.10.2015 / 21:32