Disable radio button list item via code c#

Posted on 2006-05-05
Last Modified: 2008-02-26
I have the following radio list box:

<asp:RadioButtonList id="rdoPaymentPlan" runat="server" RepeatDirection="Horizontal">
      <asp:ListItem value="Fully Earned" id="lbEarned" selected="true">Fully Earned</asp:ListItem>
      <asp:ListItem value="Annual" id="lb1" >Annual</asp:ListItem>
      <asp:ListItem value="Semi Annual" id="lb2" >Semi Annual</asp:ListItem>
      <asp:ListItem value="Quarterly" id="lb3" >Quarterly</asp:ListItem>

How can I disable/enabel a specific list item via ASP.Net 1.1 C#?  I can do it with javascript using:

lb1.disabled = false;

But how can I accomplish this via server-side?
Question by:russomr
    LVL 11

    Accepted Solution

    You can add disabled/enabled attributes to each ListItem

    LVL 11

    Expert Comment

    Here is a great article in CodeProject:

    Author Comment

    Cool.  That is a good article.  Thank you.

    One last thing, the line:  lbEarned.checked = true;  does not work in the following code.  I've tried .selected and that doesn't work either.  Remember, this is a radio button list.

    // enable payment plan if over 25,000
    if(totalPremium >= 25000) {
          lb1.disabled      = false;
          lb2.disabled      = false;
          lb3.disabled      = false;
          lbEarned.checked = true;
          lb1.disabled      = true;
          lb2.disabled      = true;
          lb3.disabled      = true;

    I will award your points regardless since you did answer my post, however if you know why the above lbEarned.checked does not work, it would be much appreciated.

    LVL 11

    Expert Comment

    You're welcome.

    I need more details regarding "lbEarned.checked does not work" in order to answer.

    Author Comment

    For the above code:

    lbEarned.checked = true;

    is the line that doesn't work.  No error occur, but the radio button of lbEarned does not become the selected radio button.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Top 6 Sources for Identifying Threat Actor TTPs

    Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

    Suggested Solutions

    Sometimes in DotNetNuke module development you want to swap controls within the same module definition.  In doing this DNN (somewhat annoyingly) swaps the Skin and Container definitions to the default admin selections.  To get around this you need t…
    A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
    Sending a Secure fax is easy with eFax Corporate ( First, Just open a new email message.  In the To field, type your recipient's fax number You can even send a secure international fax — just include t…
    Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

    794 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    17 Experts available now in Live!

    Get 1:1 Help Now