Group RADIO BUTTON and TEXT FIELD as one value for database

Posted on 2007-08-07
Medium Priority
Last Modified: 2013-11-05
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
Question by:bcoussens

Accepted Solution

TheNige earned 2000 total points
ID: 19651182
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
LVL 12

Expert Comment

ID: 19651291
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

 <asp:RadioButton1 id="radioButton1" runat="server"
                    Text="Include 8.6% sales tax"

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



Author Comment

ID: 19696716
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

        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

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
It’s a strangely common occurrence that when you send someone their login details for a system, they can’t get in. This article will help you understand why it happens, and what you can do about it.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses

862 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question