Radio Control Problem (again)

Discussion in 'ASP .Net Web Controls' started by Angela, Aug 2, 2004.

  1. Angela

    Angela Guest

    Hi

    I got some help off this forum a couple of days ago but was still not
    able to solve the problem.

    I want to use the following controls for radio buttons so that I can
    put each button into a TD cell:

    <td>
    <asp:RadioButton id="RadioButton1" groupname="Name" value="1"
    runat="server" />
    </td>
    <td>
    <asp:RadioButton id="Radiobutton2" groupname="Name" value="2"
    runat="server" />
    </td>

    I know 'value' isn't a known attribute of a radio control but that's
    the only way I could access the numerical values 1 and 2
    (Request.Form("Name"))

    Question: Is it possible to select the correct radioButton when the
    page is loaded, and if so what is the code for this? e.g. if a value
    of 2 comes back from the DB check Radiobutton2

    Thanks in advance
     
    Angela, Aug 2, 2004
    #1
    1. Advertising

  2. Angela

    DujHoD Guest

    Why are you using Request.Form? Why not just use code like this in
    your codebehind?

    if (RadioButton1.Checked)
    // The user selected RadioButton1.
    else if (Radiobutton2.Checked)
    // The user selected RadioButton2.

    Similarly, you can set the Checked property of the RadioButtons as
    soon as you get your data from the database in the codebehind.

    bool myBoolean = myDataReader.GetBoolean(0);
    RadioButton1.Checked = myBoolean;
    Radiobutton2.Checked = !myBoolean;


    (Angela) wrote in message news:<>...
    > Hi
    >
    > I got some help off this forum a couple of days ago but was still not
    > able to solve the problem.
    >
    > I want to use the following controls for radio buttons so that I can
    > put each button into a TD cell:
    >
    > <td>
    > <asp:RadioButton id="RadioButton1" groupname="Name" value="1"
    > runat="server" />
    > </td>
    > <td>
    > <asp:RadioButton id="Radiobutton2" groupname="Name" value="2"
    > runat="server" />
    > </td>
    >
    > I know 'value' isn't a known attribute of a radio control but that's
    > the only way I could access the numerical values 1 and 2
    > (Request.Form("Name"))
    >
    > Question: Is it possible to select the correct radioButton when the
    > page is loaded, and if so what is the code for this? e.g. if a value
    > of 2 comes back from the DB check Radiobutton2
    >
    > Thanks in advance
     
    DujHoD, Aug 2, 2004
    #2
    1. Advertising

  3. Angela

    Angela Guest

    Thanks for the reply,

    I guess I will have to use that method, it's just I have loads of radio
    buttons to cycle through!

    RadioButton1 - RadioButton10



    *** Sent via Developersdex http://www.developersdex.com ***
    Don't just participate in USENET...get rewarded for it!
     
    Angela, Aug 4, 2004
    #3
  4. Angela

    DujHoD Guest

    You could put them all in an array, making programmatic access easier.
    (If you wanted to get really fancy, you could even create a new
    control inheriting from RadioButtonList and make it do exactly what
    you want.)


    Angela <> wrote in message news:<#>...
    > Thanks for the reply,
    >
    > I guess I will have to use that method, it's just I have loads of radio
    > buttons to cycle through!
    >
    > RadioButton1 - RadioButton10
     
    DujHoD, Aug 4, 2004
    #4
    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. amit
    Replies:
    0
    Views:
    414
  2. Scott D Johnson
    Replies:
    1
    Views:
    1,136
    Scott D Johnson
    Sep 27, 2006
  3. Ò»Ê×Ê«

    A design problem I met again and again.

    Ò»Ê×Ê«, Apr 1, 2009, in forum: Python
    Replies:
    24
    Views:
    760
    Dennis Lee Bieber
    Apr 4, 2009
  4. Jan C. Faerber
    Replies:
    0
    Views:
    647
    Jan C. Faerber
    Jun 30, 2009
  5. Hiten
    Replies:
    1
    Views:
    711
    Vidar Petursson
    May 26, 2004
Loading...

Share This Page