質問

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;
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top