Data binding in version 1.0.2005.1

Posts   
 
    
Egor
User
Posts: 4
Joined: 12-Nov-2005
# Posted on: 12-Nov-2005 17:49:35   

Hello! simple_smile In version 1.0.2003.3 there was an opportunity to redefine in class CustomerEntity method ToString () and property Country: public new System. String Country { get {return base. Country} }

public override ToString () { return this. Country; }

At a binding countryTextBox. DataBindings. Add ("Text", order, "Customer") result was: countryTextBox. Text = "order. Customer. Country". Whether probably to make it in version 1.0.2005.1 without reception of exception "Cannot bind to property or column Customer on DataSource "?

sparmar2000 avatar
Posts: 341
Joined: 30-Nov-2003
# Posted on: 12-Nov-2005 20:46:03   

Egor, Can you try this please and let me know the result?

 countryTextBox. DataBindings. Add ("Text", customer, "Customer.Country") 
Egor
User
Posts: 4
Joined: 12-Nov-2005
# Posted on: 14-Nov-2005 09:30:46   

Good morning!

 countryTextBox. DataBindings. Add ("Text", order, "Customer.Country") 

causes exception "Cannot bind to property or column Customer on DataSource". The kind of a call is efficient only:

 countryTextBox. DataBindings. Add ("Text", order.Customer, "Country") 
Otis avatar
Otis
LLBLGen Pro Team
Posts: 39933
Joined: 17-Aug-2003
# Posted on: 14-Nov-2005 10:58:05   

why not: countryTextBox. DataBindings. Add ("Text", customer, "Country");

?

Frans Bouma | Lead developer LLBLGen Pro
Egor
User
Posts: 4
Joined: 12-Nov-2005
# Posted on: 14-Nov-2005 11:51:47   

Otis wrote:

why not: countryTextBox. DataBindings. Add ("Text", customer, "Country");

?

The data from "Country" field of property "order.Customer" will be connected?

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39933
Joined: 17-Aug-2003
# Posted on: 14-Nov-2005 12:00:15   

Egor wrote:

Otis wrote:

why not: countryTextBox. DataBindings. Add ("Text", customer, "Country");

?

The data from "Country" field of property "customer.Customer" will be connected?

Setting up these kind of databindings require an object, the property name and the name of the property to bind to. so if you want to bind 'Country' of a customer object to the Text property of a textbox, you should use the code I stated.

Frans Bouma | Lead developer LLBLGen Pro
Egor
User
Posts: 4
Joined: 12-Nov-2005
# Posted on: 14-Nov-2005 13:40:06   

I have edited a code of a call. The call

countryTextBox. DataBindings. Add ("Text", order, "Customer.Country") 

causes exception. The call

 countryTextBox. DataBindings. Add ("Text", order.Customer, "Country") 

works.

The form of a call from MSDN 'You can also use a period-delimited navigation path when you bind to an object whose properties return references to other objects (such as a class with properties that return other class objects). For example, the following navigation paths all describe valid data fields:'

"Size.Height" "Suppliers.CompanyName" "Regions.regionsToCustomers.CustomerFirstName" "Regions.regionsToCustomers.customersToOrders.ordersToDetails.Quantity" it is not efficient?

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39933
Joined: 17-Aug-2003
# Posted on: 14-Nov-2005 18:13:52   

order.Customer works because that too just returns a single object. Specifying paths in the 3rd parameter of teh Add() method only works with datasets is my understanding. At least it doesn't work always.

Frans Bouma | Lead developer LLBLGen Pro