?
Solved

Select a radio button from the radiobutton group list

Posted on 2011-09-15
4
Medium Priority
?
451 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 2000 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

Congratulations! You’re Certified – Now What?

Starting a new career can be overwhelming. Becoming certified in your field of expertise is a great start, but where do you go from here?  Here are some tips to help you on your career journey.

Question has a verified solution.

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

International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
Suggested Courses

762 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