Group RADIO BUTTON and TEXT FIELD as one value for database

Posted on 2007-08-07
Last Modified: 2013-11-27
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 24

    Accepted Solution

    If you are using databinding, you will have to make a custom binding function for the database. You can then define the .format and .parse handlers to deal with it. This is some pseudocode. First you create a new databinding between the dataset and the DB. Next you add a handler for the parse method of the binding. This method is called when the data is to be saved into the db. Finally, you define the parse method. In this case, suppose that the radiobuttons are named radiobutton_optionX and the radiobox beside the other textbox is radiobutton_other

    b = New Binding("...", dataset, "fieldname")
    AddHandler b.Parse, AddressOf CkToDB

        Public Sub CkToDB(ByVal sender As Object, ByVal e As ConvertEventArgs)
            if radiobutton_other.checked then
                    e.Value = othertextbox.value
            else if radiobutton_option1.checked then
                    e.Value = radiobutton_option1.value
            else if radiobutton_option2.checked then
                    e.Value = radiobutton_option2.value
        End Sub

    Author Comment

    thanks Mankowits,
    Unfortunatly I am not advanced as i suggested on the posting (i thought that was a discription of the question)
    I'm not really familiar with DATABINDING I am new to .NET 2.0  
    Also this list of radio buttons is dynamicaly built and i will not know how many will be there as the user can add items to this list.  will this affect the working of the code (if i have to list the valie for each radio button)
    LVL 1

    Expert Comment

    Try giving the radio buttons and the text field the same name
    LVL 24

    Expert Comment

    OK, what is the business logic you currently use to check the values of the radiobuttons? Can you show us the cod?

    Do something like this:
    [Set the database value to the name of the selected radiobutton]
    IF [the textbox contains some string] THEN [set the database value to the text in the box]

    Featured Post

    What Security Threats Are You Missing?

    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.

    Join & Write a Comment

    A theme is a collection of property settings that allow you to define the look of pages and controls, and then apply the look consistently across pages in an application. Themes can be made up of a set of elements: skins, style sheets, images, and o…
    In this article I will describe the Copy Database Wizard method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
    This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA.…
    Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

    733 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

    22 Experts available now in Live!

    Get 1:1 Help Now