I have a radio button list...
<asp:RadioButtonList ID="rblCollectOptions" runat="server" CssClass="radiolist">
<asp:ListItem Value="Collect" Text="Collect from this address"></asp:ListItem>
<asp:ListItem Value="DropOff" Text="Drop off at Depot (UK only)"></asp:ListItem>
</asp:RadioButtonList>
I also have a link button on the page to "enter address manually" which I want to set the radio button to "Collect" value.
I tried...
rblCollectOptions.SelectedIndex = 0;
and
rblCollectOptions.Items[0].Selected = true;
both work if no option is already selected, but if I manually set the radio button to another option, or set a default selection, the link button does not work.
Call ClearSelection or set SelectedIndex = -1
before you set the selected item.
rblCollectOptions.ClearSelection();
or
rblCollectOptions.SelectedIndex = -1;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With