views:

395

answers:

1

I am trying to bind a SubSonic 2.1 generated DAL object to a WinForm (VB.NET VS2005). In order to work around the lack of IPropertyNotifyChanged implementation, in my binding method I am doing a controlname.DataBindings.Clear() before a controlname.DataBindings.Add() for each control I want to bind.

Textboxes work fine with code like this (ioBLL is the reference to my BLL object, and ioDAL to the DAL property within it):

txtCountryName.DataBindings.Add(New Binding("Text", ioBLL.ioDAL, namespace.Country.Schema.Columns.GetColumn("CountryName").ToString, True, DataSourceUpdateMode.OnPropertyChanged))

but when binding to a checkbox

chkObsolete.DataBindings.Add(New Binding("Checked", ioBLL.ioDAL, namespace.Country.Schema.Columns.GetColumn("Obsolete").ToString, True, DataSourceUpdateMode.OnPropertyChanged))

it never appears ticked at runtime when the underlying property value is True.

Any ideas why?

+1  A: 

Is ioBLL.ioDAL.Obsolete a boolean ?

I use very similar code without problems.

Perhaps the only difference is that I use a BindingSource.

IE I use a bindingsource on my form and set it's DataSource to ioBLL.

Ive had other issues binding controls directly to my entities, but I dont recall the problem you describe as being one of them.

Zapatta
Thanks for your comments. Yes, it is a boolean.Since I wrote this, I wondered whether this was an instance of SubSonic not working as well with VB.NET as C#, so I bit the bullet and created a new solution with a C# DAL. This behaved fine, so I then recreated the DAL again with VB.NET, and it too worked! Must assume something wrong with my original form or BLL...Interested in your comments on using a BindingSource. Do you also create all properties in your BLL and populate them from your DAL, or do as I do and bind straight through to the DAL properties?
kevinw
My GUI calls BLL methods to fetch,save etc. BLL in turn calls the Mapper methods which populates my own entity types using calls to the Subsonic DAL. My GUI knows nothing of the Subsonic DAL and only handles my own entity types and occasionally DataTables. Something like this:GUI.bsCustomer.DataSource = BLL.CustomerBO.Fetch(New CustomerQuery().CustomerId.IsEqualTo(1001))
Zapatta
Thanks for the explanation.If I understand you correctly, you are binding to BLL.FieldName (and holding properties for each of the fields at BLL level as well as DAL level) rather than my way of populating to BLL.DAL.FieldName?
kevinw
Yes !In fact my entity base classes are built by code generators using the (in this case Subsonic) DAL dlls.
Zapatta