Solved

Binding Radio Buttons

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

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…
Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

772 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