Suppose you have the following classes in your code.
1) Address class
public class Address {
public string Street { get; set; }
public string City { get; set; }
}
2) User class
public class User {
public string UserName { get; set; }
public Address UserAddress { get; set; }
}
Now, when you want to bind the Street column to the User.Address.Street property, this, unfortunately, will not work, just setting the FieldName to "Address.Street"
But if it is important that you execute it the way you want, I would suggest that you redefine the ToString () method of the Address class as follows:
public class Address {
public string Street { get; set; }
public string City { get; set; }
public override string ToString() {
return this.Street;
}
}
"", ".", .
- readonly, UserStreet User:
public class User {
public string UserName { get; set; }
public Address UserAddress { get; set; }
public UserStreet {
get { return UserAddress != null ? UserAddress.Street : ""; }
}
}
FieldName "UserStreet".
, .