Group RADIO BUTTON and TEXT FIELD as one value for database

Hello,  I am building a web form within Visual Web Developer 2005 express and SQL express.
I have a section that collects data from radio buttions (ID: "business_type" with 10 options 1 called "other" when "other" is selected i want to capture data from the text field below these radio buttions.  
how do i group these? is that possible or do i need to link the button value "other" with the TEXT field value?  how do i do this?
Thanks in advance
bcoussensAsked:
Who is Participating?
 
TheNigeConnect With a Mentor Commented:
If you are just using asp:radiobutton controls then use the GroupName property to give them all the same group.

If the user selects your "other" one then grab the value from the textbox

If radioOther.Checked Then
   myValue = textOther.Text
End If

You can also use the asp:RadioButtonList control and that groups them all together.

If myRadioButtonList.SelectedValue = "Other" Then
   myValue = textOther.Text
End If
0
 
renjurdevanCommented:
Either you can specify same Groupname property to all radiobuttons !! or else you can use radiobutton list!!

If you want to get value when you select radiobutton then handle
CheckedChanged

 <asp:RadioButton1 id="radioButton1" runat="server"
                    AutoPostBack="True"
                    Text="Include 8.6% sales tax"
                    TextAlign="Right"
                    OnCheckedChanged="Button_Clicked"/>

  void Button_Clicked(Object sender, EventArgs e)
      {
         // Where checkbox1 is the
         if (radioButton1.Checked )
         {
        //Get value from   YourTextBox.Text
         }
      }

Regards
Renju


0
 
bcoussensAuthor Commented:
TheNige,  thankyou your solution looks like just what i need, let me clarify...

i'm building the radiobutton (id = BusinessStructure) selection dynamicaly from a table so i take it all i have to do is include a value "other" in my data and then add a text field with ID = textOther
also include this (below) in my VB file i take it i put it with my submit command?

Protected Sub btnSubmitNext_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSubmitNext.Click

        If BusinessStructure.SelectedValue = "Other" Then
            myValue = textOther.Text
        End If

        'If the page is valid, add the new product
        If Page.IsValid Then
            AddProductDataSource.Insert()

        End If
    End Sub

ALSO do i replace "myValue" with the ID of my controll i.e. "BusinessStructure"
One more question do i need to combine the IF statement for the radiobuttion and the IF statement for the Validation or can they be seperate like i have it?

Once again thankyou so much for your solution i'm sure it will work.  Ben Coussens
0
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.