.net – Data Binding in .NET with CSLA BOs


OK, I am having quite an issue with data bindings in .NET.
Some background information, my business object tier is using CSLA v1.0.
And _clientObj is passed in as a parameter as a business object that inherits CSLA.BusinessBase

Here is the code segment:

Dim nextClient As New ComboBox With { _
            .Name = "txtClientAtt" & (ClientBoxes.Count + 1).ToString(), _
            .DisplayMember = "FullNameAndID", .ValueMember = "ClientID", _
            .Tag = _clientObj}
nextClient.DataSource = ClientList.GetClientList(SelectedSite)

nextClient.DataBindings.Add("SelectedValue", _clientObj, "ClientID")
If Not _clientObj.ClientID = Nothing AndAlso nextClient.SelectedValue Is Nothing Then
     Debug.Print("How could I ever be inside this conditional????")
End If

That debug statement does indeed get reached if _clientObj is a pre-existing object with an assigned ID value. How is that possible? I was assuming that adding the data binding should immediately set the .SelectedValue property of the ComboBox if the DataSource object has an initial value.

Best Solution

If Not _clientObj.ClientID = Nothing

is not the correct way to test for a null value. You should be using:

If Not _clientObj.ClientID Is Nothing

However, I'm not sure if that is actually the issue you are having or not.