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="Ra dioList_Se lectedInde xChanged"
RepeatDirection="Horizonta l" Width="300px">
<asp:ListItem Value="type1">type1</asp:L istItem>
<asp:ListItem Value="type2">type2</asp:L istItem>
<asp:ListItem Value="type3">type3</asp:L istItem>
<asp:ListItem Value="type4">type4</asp:L istItem>
</asp:RadioButtonList>
<asp:RadioButtonList ID="radiobtnlist" runat="server" AutoPostBack="true"
onselectedindexchanged="Ra
RepeatDirection="Horizonta
<asp:ListItem Value="type1">type1</asp:L
<asp:ListItem Value="type2">type2</asp:L
<asp:ListItem Value="type3">type3</asp:L
<asp:ListItem Value="type4">type4</asp:L
</asp:RadioButtonList>
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?
foreach { ..} looks like adding onClick for each button. Is there an index field for the radio button group?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks. This is what I need. It works now.
foreach (ListItem item in radiobtnlist.Items)
{
//Doo stuff with the item
//for example:
item.Attributes.Add("onCli
}