"Cannot bind to the property or column HasItems on the DataSource" Error

"Cannot bind to the property or column HasItems on the DataSource" Error

Old forum URL: forums.lhotka.net/forums/t/60.aspx


ward0093 posted on Wednesday, May 10, 2006

Does anyone know why I can successfully setup a Button Databinding to "IsDirty" flag like so:

Button1.Databindings.Add("Enabled", MyBO, "IsDirty")

but can not set it up to a custom readonly property in my BO:

Button1.Databindings.Add("Enabled", MyBO, "HasItems")

This later binding throws the error: "Cannot bind to the property or column HasItems on the DataSource"

It doesn't make sence

ward0093

 

ajj3085 replied on Wednesday, May 10, 2006

Hi Ward,

You can't bind to those because the CSLA framework defines those IsYYY properties as [Browsable( false )], which means databinding won't bind.  You can either modify the framework to remove this, or override the property and add [Browsable( true )] to the property.

HTH
Andy

ward0093 replied on Wednesday, May 10, 2006

Thanks Andy... But binding to the "IsDirty" or "AllowEdit" actually works with no errors

my custom readonly property "HasItems" is what is failing.  Why is that?

ward0093

Mark replied on Wednesday, May 10, 2006

Andy's post regarding IsDirty, etc. is regarding CSLA 2.0.  Those particular properties are indeed marked as [Browseable(false)], so data binding does not work as it did with CSLA 1.x.

However, that has no bearing on why your custom property isn't working.

ward0093 replied on Wednesday, May 10, 2006

correct... also... I am setting these bindings up threw code at runtime... not in the designer

I keep reading posts on " PropertyDescriptor "... do I need this for my custom properties?

Mark replied on Wednesday, May 10, 2006

I wouldn't think you'd need to mess with PropertyDescriptors.  Obviously, CSLA doesn't use them, and data binding works fine.

Other than verifying that the data source you're assigning actually does expose 'HasItems', I can't think of anything else to check.  Sorry...

Mark replied on Wednesday, May 10, 2006

You should be able to do this.  I've done the exact same thing in the past.

Only thing I can think of off the top of my head is to make sure your property is public (I know I sometimes forget).  Not sure that makes much difference, because data binding depends on reflection quite a bit, but it's something to check.

ward0093 replied on Wednesday, May 10, 2006

actually... binding to AllowEdit... fails as well.... but IsDirty and IsNew all work fine...

ward0093

Copyright (c) Marimer LLC