Best use of RadioButtons

J

Jim in Arizona

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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,764
Messages
2,569,564
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top