DataBinding problem - CurrencyManager Position is always equals to -1

J

John Yung

Hi,

My program binds several controls on a WinForm to a Data Table via CurrencyManager.

Example:

txtComment.DataBindings.Add("Text", _currentDS.WithholdingTax, "Comment");
txtComment.DataBindings[0].Parse += new ConvertEventHandler(frmMain_Parse);

....

_cmCurrentRecord = (CurrencyManager)this.BindingContext[_currentDS.WithholdingTax];


The data in Data Table is retrieve via a remote call to a business object. After the data is retrieve, I call the Refresh method on the currency manager.

Before I move to .NET 2.0, the values on the form would be refresh. However, since I moved to .NET 2.0, the values no longer refresh on the screen.

After I did some debugging, I noticed the Position value of the currency manager is always at -1. So before I call the Refresh method on the currency manager, I manually set the position value to 0 (the first record on the datatable, and I vertified the record exist on the datatable). That did not help, the position value is still equals to 0.

Anyone know why this happens?

Thanks,

John Yung
 
B

Bart Mermuys

Hi,
My program binds several controls on a WinForm to a Data Table via
CurrencyManager.

Example:

txtComment.DataBindings.Add("Text", _currentDS.WithholdingTax, "Comment");
txtComment.DataBindings[0].Parse += new
ConvertEventHandler(frmMain_Parse);

....

_cmCurrentRecord =
(CurrencyManager)this.BindingContext[_currentDS.WithholdingTax];


The data in Data Table is retrieve via a remote call to a business object.
After
the data is retrieve, I call the Refresh method on the currency manager.
Before I move to .NET 2.0, the values on the form would be refresh.
However,
since I moved to .NET 2.0, the values no longer refresh on the screen.

Do you actually fill _currentDS.WithholdingTax or assign a new DataSet to
_currentDS ? If you fill it then the CurrencyManager should automatically
refresh but if you assign a new DataSet then i don't see how any refresh
will help, you will need to rebind the controls.
After I did some debugging, I noticed the Position value of the currency
manager is
always at -1. So before I call the Refresh method on the currency manager,
I manually
set the position value to 0 (the first record on the datatable, and I
vertified the record exist
on the datatable). That did not help, the position value is still equals to
0.

If Count == -1 then the underlying DataSource doesn't contain any rows.

HTH,
Greetings
 
J

John Yung

All,

I found the cause of the problem. When I made a call to the business tier
(via .NET remoting on a separate computer) to returne a new dataset, all the
binding information is gone. I guess that the binding information is not
been kept when you retrieve a dataset over .NET remoting. (I did not
experience the same problem when the business tier is run locally).

As a result, the data source for the currency manager is null. Thus,
CurrencyManager's position value is always equals to -1.

Thanks,

JY



Bart Mermuys said:
Hi,
My program binds several controls on a WinForm to a Data Table via
CurrencyManager.

Example:

txtComment.DataBindings.Add("Text", _currentDS.WithholdingTax, "Comment");
txtComment.DataBindings[0].Parse += new
ConvertEventHandler(frmMain_Parse);

....

_cmCurrentRecord =
(CurrencyManager)this.BindingContext[_currentDS.WithholdingTax];


The data in Data Table is retrieve via a remote call to a business object.
After
the data is retrieve, I call the Refresh method on the currency manager.
Before I move to .NET 2.0, the values on the form would be refresh.
However,
since I moved to .NET 2.0, the values no longer refresh on the screen.

Do you actually fill _currentDS.WithholdingTax or assign a new DataSet to
_currentDS ? If you fill it then the CurrencyManager should automatically
refresh but if you assign a new DataSet then i don't see how any refresh
will help, you will need to rebind the controls.
After I did some debugging, I noticed the Position value of the currency
manager is
always at -1. So before I call the Refresh method on the currency manager,
I manually
set the position value to 0 (the first record on the datatable, and I
vertified the record exist
on the datatable). That did not help, the position value is still equals to
0.

If Count == -1 then the underlying DataSource doesn't contain any rows.

HTH,
Greetings
Anyone know why this happens?


John Yung
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top