Group RADIO BUTTON and TEXT FIELD as one value for database

Posted on 2007-08-07
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
    LVL 7

    Accepted Solution

    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

    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

    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

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Free Trending Threat Insights Every Day

    Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

    Suggested Solutions

    This article covers the basics of the Sass, which is a CSS extension language. You will learn about variables, mixins, and nesting.
    Introduction Since I wrote the original article about Handling Date and Time in PHP and MySQL ( several years ago, it seemed like now was a good time to updat…
    HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…
    Use Wufoo, an online form creation tool, to make powerful forms. Learn how to selectively show certain fields based on user input using rules to gather relevant information and data from your forms. The rules feature provides you with an opportunity…

    759 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

    Need Help in Real-Time?

    Connect with top rated Experts

    14 Experts available now in Live!

    Get 1:1 Help Now