Best use of RadioButtons

Discussion in 'ASP .Net' started by Jim in Arizona, Sep 8, 2006.

  1. In html and ASP, I would easily code radio buttons as needed, such as:

    <input type="radio" name="question1" value="1">1</input>&nbsp;
    <input type="radio" name="question1" value="2">2</input>&nbsp;
    <input type="radio" name="question1" value="3">3</input>

    If I use the <asp:radiobutton> control, I can do this:

    <asp:RadioButton ID="RB1" GroupName="question1" runat="server" />1
    <asp:RadioButton ID="RB2" GroupName="question1" runat="server" />2
    <asp:RadioButton ID="RB3" GroupName="question1" runat="server" />3

    My problem with this is that I can't specify a value. When the form is
    filled out, I need a value between 1 and 5 to be inserted into the
    database. In the above example, the value is actually whatever the ID is
    and since I can't have duplicate IDs, then that rules out the use of
    <asp:RadioButton />.

    The <asp:radiobuttonlist /> would probably work ok but I can't place the
    radio buttons (the <asp:listitem />) side by side. It only puts the
    radio buttons vertically.

    <asp:RadioButtonList ID="RBL1" runat="server">
    <asp:ListItem>1</asp:ListItem>
    <asp:ListItem>2</asp:ListItem>
    <asp:ListItem>3</asp:ListItem>
    </asp:RadioButtonList>

    Looking at the source after the page is rendered, I can see that it
    creates a table to display the radiobuttons. The value is present
    though, which is what I would need for my database.

    I was hoping to not use <input> tags this time around and use more
    'advanced' coding techniques, but I don't know how I would go about
    using server controls considering my display and value requirements.

    Any input would be appreciated.

    TIA,
    Jim
     
    Jim in Arizona, Sep 8, 2006
    #1
    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. Sean
    Replies:
    1
    Views:
    388
    Ken Cox [Microsoft MVP]
    Aug 6, 2003
  2. RB

    RadioButtons & DataGrid

    RB, Aug 11, 2003, in forum: ASP .Net
    Replies:
    0
    Views:
    425
  3. Robert H
    Replies:
    0
    Views:
    456
    Robert H
    Dec 4, 2003
  4. Carlos
    Replies:
    0
    Views:
    287
    Carlos
    Feb 18, 2005
  5. =?Utf-8?B?Q2hyaXN0aWFhbiBOaWV1d2xhYXQ=?=

    Dynamically add RadioButtons in Repeater

    =?Utf-8?B?Q2hyaXN0aWFhbiBOaWV1d2xhYXQ=?=, May 26, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    981
    =?Utf-8?B?Q2hyaXN0aWFhbiBOaWV1d2xhYXQ=?=
    May 26, 2005
Loading...

Share This Page