Link to home
Start Free TrialLog in
Avatar of bcoussens
bcoussens

asked on

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
ASKER CERTIFIED SOLUTION
Avatar of TheNige
TheNige

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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


Avatar of bcoussens
bcoussens

ASKER

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