Home > DeveloperSection > Forums > Setting RadioButtonList selected value
Ankita Pandey
Ankita Pandey

Total Post:183

Points:1285
Posted on    January-15-2015 10:05 PM

 ASP.Net C#  .NET 
Ratings:


 1 Reply(s)
 565  View(s)
Rate this:

I am trying to select the radiobuttonlist's using the following code but it never get selected.

<asp:RadioButtonList ID="rdBond" CssClass="RadioButtonList"

                            runat="server" RepeatDirection="Horizontal">

                            <asp:ListItem>Yes</asp:ListItem>

                            <asp:ListItem>No</asp:ListItem>

                        </asp:RadioButtonList>

and I tried both of the follwing methods but doesn't work.

       ListItem l2 = rdOffset.Items.FindByValue(cd.BondReq.ToString());

        if (l2 != null)

            l2.Selected = true;

 

        rdOffset.SelectedValue = cd.Offset.ToString();

Please help to fix it.



Samuel Fernandes
Samuel Fernandes

Total Post:154

Points:1082
Posted on    January-15-2015 10:26 PM

Make this change :

  <asp:RadioButtonList ID="rdBond" CssClass="RadioButtonList"

                            runat="server" RepeatDirection="Horizontal">

                            <asp:ListItem Selected =True >Yes</asp:ListItem> <%--change this in your code--%>

                            <asp:ListItem>No</asp:ListItem>

                        </asp:RadioButtonList>


Don't want to miss updates? Please click the below button!

Follow MindStick