Radio Button GroupName and SelectedValue

I have two radio buttons that are part of a groupName. I am not sure how to go about getting the SelectedValue of the group via VB in my code behind. I am not abel to use a RadioButtonList as I have HTML code between the groped radio buttons.

Here is my code.


<table>
        <tr>
          <td><b>Do you... </b></td>
        </tr>
        <tr>
          <td>
              <asp:RadioButton ID="RadioButtonHousing" runat="server"
                  Text="Contract for Group Housing?" GroupName="RadioButtonHousingQuestions" ValidationGroup="sample" />
          </td>
        </tr>
        <tr>
          <td><b>OR</b></td>
        </tr>
        <tr>
          <td><b>Do your...</b> </td>
        </tr>
        <tr>
          <td>
           <asp:RadioButton ID="RadioButtonHousing2" runat="server"
                  Text="Attendees independently make their own housing arrangements?"
                  GroupName="RadioButtonHousingQuestions" ValidationGroup="sample" />
  </td>
        </tr>
       <tr>
          <td>
              <asp:Button ID="Button1" runat="server" Text="Button" ValidationGroup="sample"/>
            </td>
        </tr>
</table>

How do I get the selected value from the RadioButton GroupName=RadioButtonHousingQuestions above using VB code behind?

I have looked all over and most are saying use a RadioButtonList, but I can’t in this case.

Thanks for any help.

Hmm. Maybe checking for the checked state of the buttons

If RadioButtonHousing.Checked
Then
[I]...[/I]
EndIf

if you put a groupname on regular radiobutton if you have to check which one is selected and get selected value for that.

I would rather use a RadioButtonList.

<asp:RadioButtonList ID=“rdl” runat=“server”>
<asp:ListItem Value=“1”>A</asp:ListItem>
<asp:ListItem Value=“2”>B</asp:ListItem>
</asp:RadioButtonList>

then i can get the selected value as
if(rdl.SelectedIndex!=-1)
somevar=rdl.SelectedValue;

As stated above, you must check each button separately

if (RadioButtonHousing.Checked) else RadioButtonHousing2 is checked