PC Review


Reply
Thread Tools Rate Thread

BindingSource set DataSource and DataMember atomically?

 
 
Doug Crawford
Guest
Posts: n/a
 
      19th Sep 2007
I have a hierarchical structure of objects that I am using with Data
Binding. My "Application" class contains a public property named
"Status" which returns my "Status" object. I have a UserControl with
applicationBindingSource and statusBindingSource components. I am using
the VS designer to link both binding sources to various labels on my
control.

I run into problems when I set the DataSource and DataMember properties
after the InitializeComponent() call. The constructor looks like:

InitializeComponent();
applicationBindingSource.DataSource = MyApplication;
statusBindingSource.DataSource = applicationBindingSource;
statusBindingSource.DataMember = "Status";

The problem is that as soon as I set statusBindingSource.DataSource I
get an exception indicating that the DataSource was unable to bind to
the first label I have wired in the designer. I thought perhaps I need
to set statusBindingSource.DataMember first, but when I do this I get an
exception saying "DataMember property 'Status' can not be found on the
DataSource".

Interestingly, if I remove all bindings to my Labels in the VS designer
and manually set up my DataBindings after I have set
statusBindingSource.DataSource then everything works fine. It appears
like I need some way to set the DataSource and DataMemeber in one atomic
step. Also, this problem is only an issue on the compact framework.
The same code runs fine on the full framework.
 
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
Connect to BindingSource with DataMember cold80 Microsoft ADO .NET 0 26th Apr 2008 07:15 PM
Creating Browsable DataSource and DataMember properties mzwilli Microsoft C# .NET 1 31st Jan 2008 06:27 PM
BindingSource: Change DataMember Assignment at Runtime? =?Utf-8?B?cmFuZHkxMjAw?= Microsoft C# .NET 1 9th Nov 2007 10:31 PM
DataMember property 'ContractID' cannot be found on the DataSource =?Utf-8?B?QmFydA==?= Microsoft ADO .NET 6 4th Sep 2006 03:33 PM
DropDown's DataSource/DataMember John Spiegel Microsoft Dot NET 20 8th Jan 2005 09:18 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 06:58 AM.