PC Review


Reply
Thread Tools Rate Thread

Data binding to another object

 
 
Sam Martin
Guest
Posts: n/a
 
      17th Nov 2004
Hi all,

I've sorted out binding to and from my business entities, however....
Pulling data from the business entities is easy using the
<control>.DataBindings.Add(..) method. These bindings take care if
themselves from UI.
Pushing data from these objects was a bit more problematical, but discovered
that the data binder listens for <PropName>Changed events, and that it only
takes one property/event to trigger an update for the bound data object. To
create a generic "push" method in my business entities, I declared a
property in my base entity class and a method (.e.g. UpdateBound()) that
sets the common property (i.e. Entity.Data) to be Entity.Data (itself) - and
in the Data property, on the set() method i fire a DataChanged event which
the data binder handles and refreshes the bound controls for the data
object.
As long as the property in the base entity is bound to a control's property
it work fine.

This is my problem, in some cases I will need to manage mutiple business
entities from within a form so I need to know if it's possible to create
like a custom bindings for my business entities. for example bind property X
of object A to property Y of object B ?

TIA

Sam


 
Reply With Quote
 
 
 
 
Nicholas Paldino [.NET/C# MVP]
Guest
Posts: n/a
 
      17th Nov 2004
Sam,

Unfortinately, there is nothing that does that in .NET right now. I
recommend having a controller class, which has references to the two
objects, and then having it coordinate the setting of the property when the
events are fired (you could use reflection in the same way).

You ^might^ be able to get away with extending BindingsCollection, but I
don't know how much plumbing it will provide. If it provides enough, you
might be able to use it on your objects.

Hope this helps.


--
- Nicholas Paldino [.NET/C# MVP]
- (E-Mail Removed)

"Sam Martin" <(E-Mail Removed)> wrote in message
news:e$(E-Mail Removed)...
> Hi all,
>
> I've sorted out binding to and from my business entities, however....
> Pulling data from the business entities is easy using the
> <control>.DataBindings.Add(..) method. These bindings take care if
> themselves from UI.
> Pushing data from these objects was a bit more problematical, but
> discovered that the data binder listens for <PropName>Changed events, and
> that it only takes one property/event to trigger an update for the bound
> data object. To create a generic "push" method in my business entities, I
> declared a property in my base entity class and a method (.e.g.
> UpdateBound()) that sets the common property (i.e. Entity.Data) to be
> Entity.Data (itself) - and in the Data property, on the set() method i
> fire a DataChanged event which the data binder handles and refreshes the
> bound controls for the data object.
> As long as the property in the base entity is bound to a control's
> property it work fine.
>
> This is my problem, in some cases I will need to manage mutiple business
> entities from within a form so I need to know if it's possible to create
> like a custom bindings for my business entities. for example bind property
> X of object A to property Y of object B ?
>
> TIA
>
> Sam
>



 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Business object data binding hharry Microsoft ASP .NET 0 31st May 2007 09:45 PM
Binding data to object and its nested object (ASP.NET 2.0) Piotrek Microsoft ASP .NET 4 4th Aug 2006 11:09 AM
Data binding to an object Simon Verona Microsoft VB .NET 4 7th Jul 2006 09:16 AM
Object Data Binding Davie Microsoft C# .NET 2 16th Nov 2005 09:01 PM
Data Binding to a object... Simon Verona Microsoft VB .NET 19 25th Jun 2004 09:18 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 10:15 AM.