Radio buttons select

Discussion in 'ASP .Net' started by tshad, May 18, 2005.

  1. tshad

    tshad Guest

    I have 2 radio buttons set to yes or no:

    <asp:RadioButton id="RelocateYes" Checked="true" GroupName="Relocate"
    runat="server" Text="Yes"/>
    <asp:RadioButton id="RelocateNo" GroupName="Relocate" runat="server"
    Text="No"/>

    This is set as a group so that you can only choose one button. If you
    choose the other button, the first button will unselect.

    This doesn't seem to work if you do it programmatically.

    For example, if I do:

    if not (emailReader("Relocate") is DBNull.Value) then
    RelocateYes.Checked = emailReader("Relocate")
    end if

    Assume that RelocateYes is selected, so RelocateNo is not.

    If the data is 0, then RelocatYes will be unchecked. I would assume that
    RelocateNo would be checked - but it doesn't. Is there a way have it behave
    this way, or do I have to set both buttons manually?

    Thanks,

    Tom
    tshad, May 18, 2005
    #1
    1. Advertising

  2. Hello Tom,
    I would suggest using the RadioButtonList control. It is much easier to
    setup and retrieve user actions. You only deal with one control.
    --
    Bill Jones


    "tshad" wrote:

    > I have 2 radio buttons set to yes or no:
    >
    > <asp:RadioButton id="RelocateYes" Checked="true" GroupName="Relocate"
    > runat="server" Text="Yes"/>
    > <asp:RadioButton id="RelocateNo" GroupName="Relocate" runat="server"
    > Text="No"/>
    >
    > This is set as a group so that you can only choose one button. If you
    > choose the other button, the first button will unselect.
    >
    > This doesn't seem to work if you do it programmatically.
    >
    > For example, if I do:
    >
    > if not (emailReader("Relocate") is DBNull.Value) then
    > RelocateYes.Checked = emailReader("Relocate")
    > end if
    >
    > Assume that RelocateYes is selected, so RelocateNo is not.
    >
    > If the data is 0, then RelocatYes will be unchecked. I would assume that
    > RelocateNo would be checked - but it doesn't. Is there a way have it behave
    > this way, or do I have to set both buttons manually?
    >
    > Thanks,
    >
    > Tom
    >
    >
    >
    =?Utf-8?B?QmFzcyBQcm8=?=, May 19, 2005
    #2
    1. Advertising

  3. tshad

    tshad Guest

    "Bass Pro" <> wrote in message
    news:...
    > Hello Tom,
    > I would suggest using the RadioButtonList control. It is much easier to
    > setup and retrieve user actions. You only deal with one control.


    I do that in some places.

    The problem is that the RadioButtonList is set up as a table and you can't
    put the text next to the table (not sure why), it always goes below that
    text in a table cell. I fought this for awhile before just switching to the
    other control.

    Of couse, as I mention in my other post, I can't seem to set the radioButton
    programmatically, when there are more that 2 (not sure if that is the reason
    or not). The last one ends up being set, for some reason.

    Tom
    > --
    > Bill Jones
    >
    >
    > "tshad" wrote:
    >
    > > I have 2 radio buttons set to yes or no:
    > >
    > > <asp:RadioButton id="RelocateYes" Checked="true" GroupName="Relocate"
    > > runat="server" Text="Yes"/>
    > > <asp:RadioButton id="RelocateNo" GroupName="Relocate" runat="server"
    > > Text="No"/>
    > >
    > > This is set as a group so that you can only choose one button. If you
    > > choose the other button, the first button will unselect.
    > >
    > > This doesn't seem to work if you do it programmatically.
    > >
    > > For example, if I do:
    > >
    > > if not (emailReader("Relocate") is DBNull.Value) then
    > > RelocateYes.Checked = emailReader("Relocate")
    > > end if
    > >
    > > Assume that RelocateYes is selected, so RelocateNo is not.
    > >
    > > If the data is 0, then RelocatYes will be unchecked. I would assume

    that
    > > RelocateNo would be checked - but it doesn't. Is there a way have it

    behave
    > > this way, or do I have to set both buttons manually?
    > >
    > > Thanks,
    > >
    > > Tom
    > >
    > >
    > >
    tshad, May 19, 2005
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Scott D Johnson
    Replies:
    1
    Views:
    1,062
    Scott D Johnson
    Sep 27, 2006
  2. Stuart Welsh

    Radio Buttons to select A Style Sheet

    Stuart Welsh, Jan 25, 2004, in forum: Javascript
    Replies:
    0
    Views:
    69
    Stuart Welsh
    Jan 25, 2004
  3. Dave
    Replies:
    0
    Views:
    135
  4. Dr. Leff
    Replies:
    3
    Views:
    290
    David Mark
    Oct 15, 2007
  5. Dr. Leff
    Replies:
    3
    Views:
    222
    David Mark
    Oct 15, 2007
Loading...

Share This Page