Radiobutton Issue

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
 
B

bruce barker \(sqlwork.com\)

asp.net controls all use the Text property to render the value.


-- bruce (sqlwork.com)
 
J

Jim in Arizona

bruce said:
asp.net controls all use the Text property to render the value.


-- bruce (sqlwork.com)

Thanks Bruce. I'll see what I can do with that info.
 
R

Roland Dick

Hi Jim,

the radiobuttonlist has a property named "RepeatColumns" which actually
is the number of radiobuttons to display in one row. Maybe this helps as
well.

Kind Regards,

Roland
 
J

Jim in Arizona

Roland said:
Hi Jim,

the radiobuttonlist has a property named "RepeatColumns" which actually
is the number of radiobuttons to display in one row. Maybe this helps as
well.

Kind Regards,

Roland

Thanks Rick. That's actually was I was looking for. :)
 

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,995
Messages
2,570,230
Members
46,819
Latest member
masterdaster

Latest Threads

Top