Bind RadioButtons in vb 2005

How do I bind the radio button using the code below? It's asking for the property name and I can't seem to find it....thought it was Checked like a checkbox, but that doesn't work.

RBFemale.DataBindings.Add("Text", CustomerIDTable, "Female")
RBFemale.DataBindings.Add("Checked", CustomerIDTable, "Female")
'RBMale.DataBindings.Add("RadioButton", CustomerIDTable, "Male")
RBFemale.Checked = CBool(CustomerIDTable.Rows(CustomersRowPosition)("Female"))
LVL 1
mindserveAsked:
Who is Participating?
 
Éric MoreauSenior .Net ConsultantCommented:
if your fields are of type boolean, it is working:

    Private Function CreateDataSet() As DataSet
        'Creates a new dataset, 2 datatables and adds data to them
        Dim dsData As New DataSet("TestDataSet")

        Using dt As New DataTable("Countries")
            dt.Columns.Add("ID", GetType(Integer))
            dt.Columns.Add("Description", GetType(String))
            dt.Columns.Add("Check1", GetType(Boolean))
            dt.Columns.Add("Check2", GetType(Boolean))

            dt.LoadDataRow(New Object() {1, "Canada", False, True}, True)

            dsData.Tables.Add(dt)
        End Using

        Return dsData
    End Function

    Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Dim ds As DataSet

        ds = CreateDataSet()

        TextBox1.DataBindings.Add("Text", ds.Tables(0), "ID")
        TextBox2.DataBindings.Add("Text", ds.Tables(0), "Description")
        CheckBox1.DataBindings.Add("Checked", ds.Tables(0), "Check1")
        CheckBox2.DataBindings.Add("Checked", ds.Tables(0), "Check2")
        RadioButton1.DataBindings.Add("Checked", ds.Tables(0), "Check1")
        RadioButton2.DataBindings.Add("Checked", ds.Tables(0), "Check2")
    End Sub
0
 
Éric MoreauSenior .Net ConsultantCommented:
Is this working:

RBMale.DataBindings.Add("Checked", CustomerIDTable, "Male")
RBFemale.DataBindings.Add("Checked", CustomerIDTable, "Female")

What is the datatype for Male and Female columns?
Are you sure that both fields are not NULL?
0
 
mindserveAuthor Commented:
data type is boolean...
0
 
mindserveAuthor Commented:
I forgot this in the load event.....
        If RBMale.Checked = True Then
            RBMale.Text = "M"
        Else
            If RBFemale.Checked = True Then
                RBFemale.Text = "F"
            End If
        End If
0
 
Éric MoreauSenior .Net ConsultantCommented:
try my code and you will se that it is working so it is surely something in your code or in your data
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.