Problem binding to child entity [WinForms]

Posts   
 
    
paulwhit
User
Posts: 25
Joined: 21-Oct-2005
# Posted on: 21-Oct-2005 21:09:45   

Hello! I am having some binding trouble.

I have a windows form on which the user manages a collection of customers. Within this form is a custom control containing fields bound to an LLBLGen generated CustomerEntity.

I am attempting to bind the control's public CustomerEntity property to the currently selected Customer property (of CustomerEntity type) through the following code:

this.controlCustomerContact1.DataBindings.Add( "CustomerEntity",
 ((OpportunityCustomerEntity) this.opportunityCustomers[index]), "Customer" );

Customer in this case is not null, and is in fact the customer that I want. But--I get an exception ("Cannot bind to property or column Customer on DataSource")

Any ideas?

Paul.Lewis
User
Posts: 147
Joined: 22-Aug-2005
# Posted on: 22-Oct-2005 04:47:59   

paulwhit wrote:

Hello! I am having some binding trouble.

I have a windows form on which the user manages a collection of customers. Within this form is a custom control containing fields bound to an LLBLGen generated CustomerEntity.

I am attempting to bind the control's public CustomerEntity property to the currently selected Customer property (of CustomerEntity type) through the following code:

this.controlCustomerContact1.DataBindings.Add( "CustomerEntity",
 ((OpportunityCustomerEntity) this.opportunityCustomers[index]), "Customer" );

Customer in this case is not null, and is in fact the customer that I want. But--I get an exception ("Cannot bind to property or column Customer on DataSource")

Any ideas?

This link speaks to the same problem:

http://dotnet247.com/247reference/msgs/49/248125.aspx

The suggestion is to use the EndCurrentEdit method which is part of the BindingManagerBase class.

This MS may help as well:

LongURL

paulwhit
User
Posts: 25
Joined: 21-Oct-2005
# Posted on: 24-Oct-2005 22:28:28   

Paul.Lewis wrote:

This link speaks to the same problem:

http://dotnet247.com/247reference/msgs/49/248125.aspx

The suggestion is to use the EndCurrentEdit method which is part of the BindingManagerBase class.

This MS may help as well:

LongURL

Paul,

Thanks for your reply and the links. What exactly am I ending the edit on? I have tried this code

this.controlCustomerContact1.BindingContext[((OpportunityCustomerEntity) this.opportunityCustomers[index]), "Customer"].EndCurrentEdit();

But now I receive another error "cannot create a child list for field Customer".

It's a different error, so I feel like I'm making progress stuck_out_tongue_winking_eye . Do you have any guidance for the new issue?

Thanks again, Paul

Paul.Lewis
User
Posts: 147
Joined: 22-Aug-2005
# Posted on: 25-Oct-2005 05:20:03   

Do you have any guidance for the new issue?

  • Ensure "customer" is spelled correctly and matches a attribute in your entity
  • Ensure your binding to an entity and not an entity attribute
  • Ensure you don't have extra spaces within the quoted constants

It's going to be something obvious...once you find it! disappointed

paulwhit
User
Posts: 25
Joined: 21-Oct-2005
# Posted on: 03-Nov-2005 17:17:39   

Paul.Lewis wrote:

Do you have any guidance for the new issue?

  • Ensure "customer" is spelled correctly and matches a attribute in your entity
  • Ensure your binding to an entity and not an entity attribute
  • Ensure you don't have extra spaces within the quoted constants

It's going to be something obvious...once you find it! disappointed

Paul, thanks again for the reply. I didn't change the code at all, but we upgraded our project to VS 2005 and all is well. Everything works, and I don't have to do the EndCurrentEdit(). smile

paulwhit
User
Posts: 25
Joined: 21-Oct-2005
# Posted on: 11-Nov-2005 17:37:21   

OK, I have another question related to this issue. I was successful in binding to my child object using this syntax

this.controlCustomerContact1.DataBindings.Add("CustomerEntity", ((OpportunityCustomerEntity)this.OpportunityCustomers[index]), "Customer");

Everything seems to be hunky-dory except that for every key press I get several "out of sync" exceptions.

In this case I don't mind so much that it's out of sync because I'm saving when the user clicks off of the form. Is there a way to disable the synchronization check, or a better way to handle this issue?

Thanks again, Paul

sparmar2000 avatar
Posts: 341
Joined: 30-Nov-2003
# Posted on: 12-Nov-2005 19:29:44   

Paul, Have a look at this

http://www.codeproject.com/cs/database/CurrencyMangersCollection.asp

.

Hopefuly it will be of some help.

paulwhit
User
Posts: 25
Joined: 21-Oct-2005
# Posted on: 14-Nov-2005 22:00:38   

Thanks for the response. Isn't this exception an LLBLGen message, however, and not an issue with the bindings?

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39930
Joined: 17-Aug-2003
# Posted on: 15-Nov-2005 11:05:30   

paulwhit wrote:

Thanks for the response. Isn't this exception an LLBLGen message, however, and not an issue with the bindings?

Outofsync is indeed an LLBLGen Pro message. It means that an entity was saved, but not refetched. You can refetch an entity after it's saved by using one of the SaveEntity() overloads which accept a boolean for refetch.

Frans Bouma | Lead developer LLBLGen Pro