Solved

Select a radio button from the radiobutton group list

Posted on 2011-09-15
4
448 Views
Last Modified: 2012-05-12
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>

0
Comment
Question by:minglelinch
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 7

Expert Comment

by:Norush
ID: 36543577
Try with:


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

Author Comment

by:minglelinch
ID: 36543762
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?

0
 
LVL 7

Accepted Solution

by:
Norush earned 500 total points
ID: 36543850
Something like this ?

int i;
i = 1;  //Get your value from the DB here
radiobtnlist.Items[i].Selected = true;

Open in new window

0
 
LVL 1

Author Closing Comment

by:minglelinch
ID: 36544372
Thanks. This is what I need. It works now.
0

Featured Post

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
In this video, viewers will be given step by step instructions on adjusting mouse, pointer and cursor visibility in Microsoft Windows 10. The video seeks to educate those who are struggling with the new Windows 10 Graphical User Interface. Change Cu…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …

687 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question