Hey,
I have a RadioButtonList wich contain 4 radio buttons A,B,C,D
RBQ.Items.Add("A")
RBQ.Items.Add("B")
RBQ.Items.Add("C")
RBQ.Items.Add("D")
How can set the selected value to the radio button who has the value "B" ????
Thanks.
Hey,
I have a RadioButtonList wich contain 4 radio buttons A,B,C,D
RBQ.Items.Add("A")
RBQ.Items.Add("B")
RBQ.Items.Add("C")
RBQ.Items.Add("D")
How can set the selected value to the radio button who has the value "B" ????
Thanks.
RBC.Items.FindByValue("B").Selected = True
or
RBC.SelectedValue = 2
Grz, Kris.
On aspx-Page:
<asp:RadioButtonList ID="RadioButtonList1" runat="server">
<asp:ListItem>A</asp:ListItem>
<asp:ListItem Selected="True">B</asp:ListItem>
<asp:ListItem>C</asp:ListItem>
<asp:ListItem>D</asp:ListItem>
</asp:RadioButtonList>
In Codebehind:
Dim item As New ListItem("A", "A")
Me.RadioButtonList1.Items.Add(item)
item = New ListItem("B", "B")
item.Selected = True
Me.RadioButtonList1.Items.Add(item)
item = New ListItem("C", "C")
Me.RadioButtonList1.Items.Add(item)
item = New ListItem("D", "D")
Me.RadioButtonList1.Items.Add(item)
or
Me.RadioButtonList1.SelectedValue = "B"