PC Review


Reply
Thread Tools Rate Thread

DataBinding problem - CurrencyManager Position is always equals to -1

 
 
John Yung
Guest
Posts: n/a
 
      16th Nov 2005
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


 
Reply With Quote
 
 
 
 
Bart Mermuys
Guest
Posts: n/a
 
      16th Nov 2005
Hi,

>"John Yung" <(E-Mail Removed)> wrote in message
>news:(E-Mail Removed)...
>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?



>Thanks,


>John Yung



 
Reply With Quote
 
John Yung
Guest
Posts: n/a
 
      18th Nov 2005
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" <(E-Mail Removed)> wrote in message
news:%(E-Mail Removed)...
> Hi,
>
> >"John Yung" <(E-Mail Removed)> wrote in message
> >news:(E-Mail Removed)...
> >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?

>
>
> >Thanks,

>
> >John Yung

>
>



 
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
help with currencymanager position =?Utf-8?B?cm9zc3U=?= Microsoft ADO .NET 2 4th Dec 2005 10:37 PM
DataBinding problem - CurrencyManager Position is always equals to -1 John Yung Microsoft Dot NET Framework Forms 2 18th Nov 2005 04:58 PM
Is CurrencyManager and DataBinding worth it? Johann Blake Microsoft C# .NET 2 20th Sep 2005 03:39 PM
Damn dirty databinding - why is CurrencyManager.Position changing??? Robert C. Nell Microsoft Dot NET Framework Forms 0 2nd Jun 2005 11:13 PM
problem updating CurrencyManager.Position when binding to a custom object's ArrayList property Bob DeRemer Microsoft Dot NET Framework Forms 4 13th Oct 2004 08:58 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 01:07 PM.