?
Solved

Binding Radio Buttons

Posted on 2009-07-16
4
Medium Priority
?
444 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 400 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

NEW Veeam Agent for Microsoft Windows

Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!

Question has a verified solution.

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

Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…

770 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