Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 91083
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T22:58:28+00:00 2026-05-10T22:58:28+00:00

I have a binary field in my database that is hard to describe in

  • 0

I have a binary field in my database that is hard to describe in a UI using a single ‘Is XXXX?’-type checkbox. I’d rather use a pair of radio buttons (e.g. ‘Do it the Foo way’ and ‘Do it the Bar way’), but right now all the other fields on my form are data-bound to a business object. I’d like to data-bind the pair of radio buttons to the business object as well, but haven’t come up with a good way to do it yet. I can bind one of the buttons to the field, such that the field is set ‘true’ if the button is selected, but while selecting the other button does de-select the first one (that is, the two radio buttons are properly paired), the value of the field does not update to reflect this.

I’d like to be able to say

button1.DataBindings.Add(new Binding('checked', source, 'useFoo')); button2.DataBindings.Add(new Binding('checked', source, '!useFoo')); 

but I’m pretty sure that will throw when it runs. Is there an easier way, or should I just put more thought into how to word a single checkbox? I don’t want to add extra functions to handle something this trivial…

ETA: A commenter has suggested considering a dropdown (ComboBox). I had thought about this, but how would I data-bind that to a boolean field in a database/Property in a business object? If I bind the SelectedItem to the useFoo property, what would go in the Items collection? Would I have to add just ‘True’ and ‘False’, or could I somehow add a key/value pair object that ties a displayed item (‘Use Foo’ / ‘Do Not Use Foo’) to the boolean value behind it? I’m having trouble finding docs on this.


About the answer: the solution I wound up using involved modifying the business object — the basic idea is very similar to the one posted by Gurge, but I came up with it separately before I read his response. In short, I added a separate property that simply returns !useFoo. One radio button is bound to source.UseFoo, and the other is bound to source.UseBar (the name of the new property). It’s important to make sure the new property has both getters and setters, or you’ll wind up with really odd behavior.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-10T22:58:28+00:00Added an answer on May 10, 2026 at 10:58 pm

    I have found a way of doing this using DataSet/DataTable.

    I make a calculated column in the DataTable with the expression IIF(Foo=true, false, true). Let’s call that column Bar.

    Bar is of type Boolean. Now you can bind one RadioButton.Checked to Foo and one to Bar.

    To get Bar checking/unchecking to propagate back to Foo you must go to the generated DataTable code and add one line, the last one in this sample:

    [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] public bool Bar {     get {         try {             return ((bool)(this[this.tableradio.BarColumn]));         }         catch (global::System.InvalidCastException e) {             throw new global::System.Data.StrongTypingException('The value for column \'Bar\' in table \'radio\' is DBNull.', e);         }     }     set {         this[this.tableradio.BarColumn] = value;         this[this.tableradio.FooColumn] = !value;     } } 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 123k
  • Answers 123k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Additionally, you should look at the error info. Part of… May 12, 2026 at 1:01 am
  • Editorial Team
    Editorial Team added an answer Your code works as is. It is just that your… May 12, 2026 at 1:01 am
  • Editorial Team
    Editorial Team added an answer As far as I know Stack Overflow and Server Fault are both… May 12, 2026 at 1:01 am

Related Questions

Problem description: In my application, I have to present the contents of data packets
I am working on a VB6 application that uses an ADODB.Recordset object to dump
I have a JavaScript slideshow that pre-loads images out of a MySQL database and
I have a class of data with a very large number of binary properties--151

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.