How to control a Radiobuttonlist via code

Asked

Viewed 945 times

1

I am 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 wish when the Geral of the Group was selected, automatically the Geral Sub Group was also selected.

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

  • You can set the other general, in the Group General Onclick. There you select it.

  • That’s just my life, how to do it ? Could post some example code please ?

1 answer

1

Something more or less like this:

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

Or so:

boolean radio;  
radio =  radiobutton.isSelected(); 

then you check:

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

See if it solves your problem

I saw that you use Radiobuttonlist, so it would be something like this:

if(RadioGrupo.SelectedIndex == 0){
 radiosubgrupo.selectedindex = 0
else
....
}

Browser other questions tagged

You are not signed in. Login or sign up in order to post.