Nate Pet
Nate Pet

Reputation: 46322

vb.net radio button selection

I have the following in vb.net

 <asp:RadioButtonList ID="rbEdit5" runat="server"  RepeatDirection="horizontal" >
  <asp:ListItem Value="1" >Yes</asp:ListItem>
  <asp:ListItem Value="0" >No</asp:ListItem>
 </asp:RadioButtonList>

I need to programatically select one of the 2 listitems. How do I programatically select say 'Yes' above in vb.net

Upvotes: 2

Views: 1689

Answers (3)

Matt
Matt

Reputation: 2098

For Each li As ListItem In rbEditTop25.Items
     If li.Text= "Yes" Then
       li.Selected = True
     End If
Next

Upvotes: 0

James Johnson
James Johnson

Reputation: 46067

This should work:

rbEditTop25.Items.FindByText("Yes").Selected = True

Upvotes: 2

GShenanigan
GShenanigan

Reputation: 5493

rbEditTop25.SelectedValue = "1"

Should do the trick!

Upvotes: 0

Related Questions