Windows Develop Bookmark and Share   
 index > Windows Forms Data Controls and Databinding > Cannot bind dataconnector to empty collection
 

Cannot bind dataconnector to empty collection

Hi, I have a serious problem I cannot solve more than tree months. I will be very glad, if there is someone who can help me.
Here is a description of my problem:

I have a class Customers which implements IBindingList interface for better communication with dataconnector. It can include many instances of Customer object, which represents data about one customer. The problem is that when I open a new contract, it has no customers, and therefore bindings fails, and window form shuts down.

If you can solve this, please write me (please send me also mail to futtech@atlas.sk)
Many times, thanks.
MigrationUser 1  Friday, March 04, 2005 11:49 AM
Can you please elaborate how you are binding. This should work fine:
DataConnector dc = new DataConnector();
dc.DataSource = new Customers(); // where Customers is an IBindingList

You can then add Customer objects to the Customers or you can again bind the DataConnector to the new Customers object.

You can alternatively bind the DataConnector to a System.Type() - in this case the DataConnector will create a BindingList<T> internally and you can add more objects to the list by calling DataConnector.Add(...)

To read more on how you can bind different objects to the DataConnector, check this out: http://blogs.msdn.com/dchandnani/archive/2005/03/15/396387.aspx 

HTH,
-Dinesh Chandnani
MigrationUser 1  Wednesday, March 16, 2005 3:52 PM

You can use google to search for other answers

Custom Search

More Threads

• Error Reading in Value from current row of datagrid
• DataGridViewComboBox Cell's selected value disappears
• dynamically binding data to a combobox in datagridview
• how we can create trial application using vb.net?
• Grid in the grid
• New Row in bound grid: default value not set in data source
• System.NullReferenceException when clicking column header
• refreshing datagrid
• Insert last vallue to text field
• DataGridView EditingControl.KeyUp event strange behaviour