Link to home
Start Free TrialLog in
Avatar of minglelinch
minglelinch

asked on

Select a radio button from the radiobutton group list

How can I select a radiobutton from the grouplist at C# server side? Thanks.

                       <asp:RadioButtonList ID="radiobtnlist" runat="server" AutoPostBack="true"
                               onselectedindexchanged="RadioList_SelectedIndexChanged"
                               RepeatDirection="Horizontal" Width="300px">
                               <asp:ListItem Value="type1">type1</asp:ListItem>
                               <asp:ListItem Value="type2">type2</asp:ListItem>
                               <asp:ListItem Value="type3">type3</asp:ListItem>
                               <asp:ListItem Value="type4">type4</asp:ListItem>
                         </asp:RadioButtonList>

Avatar of Norush
Norush
Flag of Netherlands image

Try with:


                  foreach (ListItem item in radiobtnlist.Items)
                  {
                        //Doo stuff with the item
                        //for example:
                        item.Attributes.Add("onClick", "resumeHeaderFormattingStyle = 'resumeStyleHeading10'; resumeContentFormattingStyle = 'resumeStyleContent10';");
                  }
Avatar of minglelinch
minglelinch

ASKER

What I'm doing is - Based on the value I got fom DB, I need to select the coresponding radio button,maybe the first, the second one  or the third, the four one.

foreach { ..} looks like adding onClick for each button. Is there an index field for the radio button group?

ASKER CERTIFIED SOLUTION
Avatar of Norush
Norush
Flag of Netherlands image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks. This is what I need. It works now.