how to bind a radio button to a SQL bit field or what data type to use for gender of a person in an

N

Neo

I put a similar post for CheckBoxes,
but i want to use a Radio button & not a CheckBox

I have a field named "Male" & this is of SQL BIT data type (SQL Server).
How can i bind this field to a check box?

I noticed that this field can be NULL, 0 or 1.
But i'm having trouble binding this field to my check box.

i get an error when i try the following,

'oDataTable is the Data Table with the relevant record & having the field
"Male"
RadionButton.DataBindings.Add("Checked", oDataTable, "Male")

I have 2 radio buttons, both put into a panel (so that only one can be
checked at a time).
& for the data binding, i am binding ONLY one radio button to the data
field.

Else, whats the best way to store the gender of a person - what should the
data type of the field be?
 
K

Ken Tucker [MVP]

Hi,

Maybe this will help.
http://msdn.microsoft.com/msdnmag/issues/04/07/advancedbasics/default.aspx

Ken
-----------------------
I put a similar post for CheckBoxes,
but i want to use a Radio button & not a CheckBox

I have a field named "Male" & this is of SQL BIT data type (SQL Server).
How can i bind this field to a check box?

I noticed that this field can be NULL, 0 or 1.
But i'm having trouble binding this field to my check box.

i get an error when i try the following,

'oDataTable is the Data Table with the relevant record & having the field
"Male"
RadionButton.DataBindings.Add("Checked", oDataTable, "Male")

I have 2 radio buttons, both put into a panel (so that only one can be
checked at a time).
& for the data binding, i am binding ONLY one radio button to the data
field.

Else, whats the best way to store the gender of a person - what should the
data type of the field be?
 
C

Cor Ligthert

Neo,

A radiobutton is a state: something is a man or a woman.
When it is not a man than it is a woman in your case.

So the radiobutton should work with binding when you have only one
datafield. The field tells Male = true, than Woman = false. To find the
rigth text with that is always a problem because one of those genders feels
them often discriminated.

When you don't want that, than you can try the binding events

http://msdn.microsoft.com/library/d...frlrfSystemWindowsFormsBindingEventsTopic.asp

The samples are at the individual events

I hope this helps?

Cor
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top