Solved

Binding Radio Buttons

Posted on 2009-07-16
4
437 Views
Last Modified: 2012-05-07
Hi Thanks for clicking.

This is something you'd think was easy, but the hassle it's given me.

Want to Bind to 7 radio buttons a Text database field

This Text field can have 7 states, namely Intruder, Fire, Access, Social, Vehicle, CCTV and Other

Obviously the 7 buttons fit exactly to this. So obviously we choose the appropriate one upon Binding.

However, what do we bind to?? Thought of using a FlowPanel ( a fancy panel) , and using the Tag property of this to bind to this field. After that we interpret the Tag property and therefore check or uncheck the appropriate radio button.

Vice Versa, when we change the Radio button we manually change the Tag property of the Panel, and therefore should upload as normal on save like any other control on our form.

Which property and what event of the Panel shoud I use to do this job?? Tried using the Tag property and BindingContextChanged event, but doesn't change the Tag property for some reason, even though it's bound.

We use VS2005 and SQLSERVER2005

I'd be most grateful
0
Comment
Question by:StuartK
  • 2
  • 2
4 Comments
 
LVL 83

Expert Comment

by:CodeCruiser
ID: 24876589
>This Text field can have 7 states, namely Intruder, Fire, Access, Social, Vehicle, CCTV and Other
Do you mean you store 7 strings in one field delimited with some character? Then why you need radio buttons? Why not checkboxes? Please explain in detail. Are you using design time binding?
0
 

Accepted Solution

by:
StuartK earned 0 total points
ID: 24877348
First off thanks for posting
We are using Design Time Binding. We also use a BindingSource control
As for the field it is a String field called "Description" and can be only one of the 7 choices namely Intruder, Fire, Access, Social, Vehicle, CCTV and Other
Depending what that field is we want to Depress one of the 7 toggle buttons (radio buttons with Appearance property set to "Button") namely btnIntruder, btnFire, btnAccess, btnSocial, btnVehicle, btnCCTV and btnOther.
Then if the toggle buttons are pressed by the user and Save is done, the database field "Description" changes to reflect that change.
Any thoughts?? This should be easy, don't know why it's proved such a problem, but it has. I search all the internet and nothing works for Binding.
Thanks Stu
0
 
LVL 83

Assisted Solution

by:CodeCruiser
CodeCruiser earned 100 total points
ID: 24877361
I think you have to inherit the default radio button because radio button binds to boolean fields. The inherited control would check the Description field for a text string and if that string matches its name or tag property (whichever you decide to use) then the radio button would set itself checked. Here is an example of inheriting

http://www.experts-exchange.com/Programming/Languages/.NET/ASP.NET/Q_24568376.html?cid=1131#a24857560
0
 

Author Comment

by:StuartK
ID: 24934188
Sorted by using controls from Janus Suite. This allows a CheckedValue property to bind to the radio button set up as a toggle button,and also binding using a BindableValue property.
Thanks for all your help, I always award points even for suggestions that didn't turn out to be my particular solution, but might well be others.
0

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

Suggested Solutions

Title # Comments Views Activity
crm development 2 37
Need an intro to -- .Net SQL Authorization Manager 7 51
Code enhancement 5 14
Check if number is currency 15 29
This document covers how to connect to SQL Server and browse its contents.  It is meant for those new to Visual Studio and/or working with Microsoft SQL Server.  It is not a guide to building SQL Server database connections in your code.  This is mo…
It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

747 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

12 Experts available now in Live!

Get 1:1 Help Now