5

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.

Stuart
  • 1,544
  • 5
  • 29
  • 45

1 Answers1

2

Call ClearSelection or set SelectedIndex = -1 before you set the selected item.

rblCollectOptions.ClearSelection();

or

rblCollectOptions.SelectedIndex = -1;
Adil
  • 146,340
  • 25
  • 209
  • 204
  • Perfect! thanks, I didn't think of this I thought it would have worked the same way as a `dropdownlist`. – Stuart Mar 13 '13 at 11:11