Solved

Binding Radio Buttons

Posted on 2009-07-16
4
438 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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

Suggested Solutions

More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
Delivering innovative fully-managed cloud services for mission-critical applications requires expertise in multiple areas plus vision and commitment. Meet a few of the people behind the quality services of Concerto.
A company’s greatest vulnerability is their email. CEO fraud, ransomware and spear phishing attacks are the no1 threat to a company’s security. Cybercrime is responsible for the largest loss of money to companies today with losses projected to r…

914 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