ASP RadioButton Value?

I added group of  <asp:RadioButton> to my page, set it's text value and then went to set the value property but apparently there is no value property.  (huh???)

RadioButtonList doesn't work for me because I wish to style my 10 RadioButtons in 2 columns and 5 rows versus having them all stack up vertically.  (unless there is a way to do this that I'm not aware of)

So I'm confused.  RadioButtonList allows me to assign values but a plain old RadioButton does not.  

Who is Participating?
Carl TawnConnect With a Mentor Systems and Integration DeveloperCommented:
Great isn't it! Two steps forward and one step back and all that.

Anyway, like you've already said you'll have to resort to a RadioButtonList (or use some convoluted mapping behind the scenes) if you want to supply a value. Luckily the RadioButtonList will allow you to put the radio buttons into columns using the RepeatColumns and RepeatDirection properties.
A <asp:RadioButton> is nothing more than the ASP.NET representation of an <input type="radio">. It has bells and whistles hung on it, but in essense it has not value property because this is actually set by the text property (they should have named the text property "value" to be more clear).

A <asp:RadioButtonList> allows for text and value properties because it builds labels for each <input> it builds, assigning Text to the label and Value to the <input>. in short it makes sense that there is no text & value property.

To make a <asp:RadioButtonList> behave in the way you described you can set the RepeatDirection and RepeatColumns properties (Note: there is also a RepeatLayout property that will control whether it renders a <table> or using <div> tags.

So you can do this to get two columns, hope that helps:
<asp:RadioButtonList ID="rb1" runat="server" RepeatDirection="Horizontal" RepeatColumns="2">
      <asp:ListItem Text="rb1" Value="1"></asp:ListItem>
      <asp:ListItem Text="rb2" Value="2"></asp:ListItem>
      <asp:ListItem Text="rb3" Value="3"></asp:ListItem>
      <asp:ListItem Text="rb4" Value="4"></asp:ListItem>
      <asp:ListItem Text="rb5" Value="5"></asp:ListItem>
      <asp:ListItem Text="rb6" Value="6"></asp:ListItem>
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.