Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Adding record to an empty dataset and databinding to a form

Status
Not open for further replies.

xai999

Programmer
Apr 7, 2005
24
NL
I have this form wich contians a dataset that can be empty in certain conditions. When I add the first record to this dataset it doesn't show this record in the bound controls on the form (I know for shure, cause the values differ from the values initialized in the new record).

I tried calling the refresh on the currencymanager like this

(this.BindingContext[ periodDataSet1, "Period" ] as CurrencyManager).Refresh();

But it results in the following exception:
"DataBinding could not find a row in the list that is suitable for all bindings"

I've also tried calling SuspendBinding and then ResumeBinding, but then the resumebinding also causes this exception.

And then silence smacks right in there...
... And it is loud!
 
Dear xai999,
As far as i could understand the situation, u have a dataset bound to a control and not all times this dataset holds data.
I imagine it like this:
1. Check ur condition to fill the dataset and (fill it if true) (Leave it empty if false)
2. Bind the dataset to the control

I hope i could understand it
 
Sorry for the scares information, but my code is spread throughout several classes.

Fill is called everytime the form opens, also when there is no data.

You're saying I shouldn't call fill when there is no data?

And then silence smacks right in there...
... And it is loud!
 
I've made a small testprogram, but in there it does work, so there's a problem with my code somewhere.
Will keep you informed.

And then silence smacks right in there...
... And it is loud!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top