asp:RadioButtonList doesn't set correct selected item on load

Posted by Nir on Stack Overflow See other posts from Stack Overflow or by Nir
Published on 2010-04-13T08:29:40Z Indexed on 2010/04/13 8:33 UTC
Read the original article Hit count: 517

Filed under:
|
|

I have this code:

<asp:RadioButtonList ID="rblExpDate" runat="server" >
    <asp:ListItem Selected="True" Text="No expiration date"></asp:ListItem>
    <asp:ListItem Text="Expires on:"></asp:ListItem>
</asp:RadioButtonList>

that I would like to be always, on page load, to mark the first option ("no expiration date"). However, if the user marks the second option and reloads, the second option is selected, even though I do this on page load:

rblExpDate.Items[0].Selected = true;
rblExpDate.SelectedIndex = 0;

Appreciate your help!

© Stack Overflow or respective owner

Related posts about c#3.5

Related posts about ASP.NET