? about currencymanager & relations

  • Thread starter Thread starter D
  • Start date Start date
D

D

hi

I have a form with 2 datagrids showing related table data in a master /
child or order / order details type relationship. I would like to auto
select the row in the order details table which contains the highest priced
item. My thoughts were to get the currency manager from the orderdetails
table and iterate thru each row and keep track of the highest item and row
and select that when done. I have found that for some reason the currency
manager of the order details table is always a position 0 regardless of what
is actually showing in the order details datagrid.

What am I doing wrong?

Thanks !!
 
D,

Are you sure you are getting the correct currency mananger? When you
are getting the currency manager, you need to get the manager which is
returned to you by using the DataRelation as the key, not the child data
table (which is why the position is probably always zero).

Hope this helps.
 
I thought of that but I must have the syntax wrong because I'm getting
exceptions

_dsTests.Relations.Add("MyTestRelation",
_dsCombinations.Tables["Tests"].Columns["ID"],
_dsCombinations.Tables["DailyTotals"].Columns["ID"]);
later...
CurrencyManager myCurrencyManager =
(CurrencyManager)this.BindingContext["MyTestRelation"];
cast not valid
CurrencyManager myCurrencyManager =
(CurrencyManager)this.BindingContext["Tests.MyTestRelation"];
cast not valid

Thanks


Nicholas Paldino said:
D,

Are you sure you are getting the correct currency mananger? When you
are getting the currency manager, you need to get the manager which is
returned to you by using the DataRelation as the key, not the child data
table (which is why the position is probably always zero).

Hope this helps.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

D said:
hi

I have a form with 2 datagrids showing related table data in a master /
child or order / order details type relationship. I would like to auto
select the row in the order details table which contains the highest
priced item. My thoughts were to get the currency manager from the
orderdetails table and iterate thru each row and keep track of the
highest item and row and select that when done. I have found that for
some reason the currency manager of the order details table is always a
position 0 regardless of what is actually showing in the order details
datagrid.

What am I doing wrong?

Thanks !!
 
D,

Don't pass the string with the data relation name to the BindingContext.
Rather, pass the data relation itself, and you should get it.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

D said:
I thought of that but I must have the syntax wrong because I'm getting
exceptions

_dsTests.Relations.Add("MyTestRelation",
_dsCombinations.Tables["Tests"].Columns["ID"],
_dsCombinations.Tables["DailyTotals"].Columns["ID"]);
later...
CurrencyManager myCurrencyManager =
(CurrencyManager)this.BindingContext["MyTestRelation"];
cast not valid
CurrencyManager myCurrencyManager =
(CurrencyManager)this.BindingContext["Tests.MyTestRelation"];
cast not valid

Thanks


Nicholas Paldino said:
D,

Are you sure you are getting the correct currency mananger? When you
are getting the currency manager, you need to get the manager which is
returned to you by using the DataRelation as the key, not the child data
table (which is why the position is probably always zero).

Hope this helps.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

D said:
hi

I have a form with 2 datagrids showing related table data in a master /
child or order / order details type relationship. I would like to auto
select the row in the order details table which contains the highest
priced item. My thoughts were to get the currency manager from the
orderdetails table and iterate thru each row and keep track of the
highest item and row and select that when done. I have found that for
some reason the currency manager of the order details table is always a
position 0 regardless of what is actually showing in the order details
datagrid.

What am I doing wrong?

Thanks !!
 
I'm afraid I'm still getting an invalid cast exception error when trying to
do

CurrencyManager myCurrencyManager =
(CurrencyManager)this.BindingContext[_dsTests.Relations["MyTestRelation"]];

I have a feeling that I'm going to have to get current id from the Tests
table and seek out the highest totals in the DailyTotals manually.


Nicholas Paldino said:
D,

Don't pass the string with the data relation name to the
BindingContext. Rather, pass the data relation itself, and you should get
it.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

D said:
I thought of that but I must have the syntax wrong because I'm getting
exceptions

_dsTests.Relations.Add("MyTestRelation",
_dsCombinations.Tables["Tests"].Columns["ID"],
_dsCombinations.Tables["DailyTotals"].Columns["ID"]);
later...
CurrencyManager myCurrencyManager =
(CurrencyManager)this.BindingContext["MyTestRelation"];
cast not valid
CurrencyManager myCurrencyManager =
(CurrencyManager)this.BindingContext["Tests.MyTestRelation"];
cast not valid

Thanks


Nicholas Paldino said:
D,

Are you sure you are getting the correct currency mananger? When you
are getting the currency manager, you need to get the manager which is
returned to you by using the DataRelation as the key, not the child data
table (which is why the position is probably always zero).

Hope this helps.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

hi

I have a form with 2 datagrids showing related table data in a master /
child or order / order details type relationship. I would like to auto
select the row in the order details table which contains the highest
priced item. My thoughts were to get the currency manager from the
orderdetails table and iterate thru each row and keep track of the
highest item and row and select that when done. I have found that for
some reason the currency manager of the order details table is always a
position 0 regardless of what is actually showing in the order details
datagrid.

What am I doing wrong?

Thanks !!
 
D,

What is the type that is returned when you key on the relation? What
does the debugger tell you?


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

D said:
I'm afraid I'm still getting an invalid cast exception error when trying
to do

CurrencyManager myCurrencyManager =
(CurrencyManager)this.BindingContext[_dsTests.Relations["MyTestRelation"]];

I have a feeling that I'm going to have to get current id from the Tests
table and seek out the highest totals in the DailyTotals manually.


Nicholas Paldino said:
D,

Don't pass the string with the data relation name to the
BindingContext. Rather, pass the data relation itself, and you should get
it.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

D said:
I thought of that but I must have the syntax wrong because I'm getting
exceptions

_dsTests.Relations.Add("MyTestRelation",
_dsCombinations.Tables["Tests"].Columns["ID"],
_dsCombinations.Tables["DailyTotals"].Columns["ID"]);
later...
CurrencyManager myCurrencyManager =
(CurrencyManager)this.BindingContext["MyTestRelation"];
cast not valid
CurrencyManager myCurrencyManager =
(CurrencyManager)this.BindingContext["Tests.MyTestRelation"];
cast not valid

Thanks


in message D,

Are you sure you are getting the correct currency mananger? When
you are getting the currency manager, you need to get the manager which
is returned to you by using the DataRelation as the key, not the child
data table (which is why the position is probably always zero).

Hope this helps.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

hi

I have a form with 2 datagrids showing related table data in a master
/ child or order / order details type relationship. I would like to
auto select the row in the order details table which contains the
highest priced item. My thoughts were to get the currency manager from
the orderdetails table and iterate thru each row and keep track of the
highest item and row and select that when done. I have found that for
some reason the currency manager of the order details table is always
a position 0 regardless of what is actually showing in the order
details datagrid.

What am I doing wrong?

Thanks !!
 
I'm not sure where to look for that, I mean I catch the exception but I
don't see where it reads about the actual object. After reading MSDN a bit I
tried casting it to a propertymanager which workd but I'm not sure what to
do next. More reading I guess.

Any thoughts?

Thanks for your help.


Nicholas Paldino said:
D,

What is the type that is returned when you key on the relation? What
does the debugger tell you?


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

D said:
I'm afraid I'm still getting an invalid cast exception error when trying
to do

CurrencyManager myCurrencyManager =
(CurrencyManager)this.BindingContext[_dsTests.Relations["MyTestRelation"]];

I have a feeling that I'm going to have to get current id from the Tests
table and seek out the highest totals in the DailyTotals manually.


Nicholas Paldino said:
D,

Don't pass the string with the data relation name to the
BindingContext. Rather, pass the data relation itself, and you should
get it.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

I thought of that but I must have the syntax wrong because I'm getting
exceptions

_dsTests.Relations.Add("MyTestRelation",
_dsCombinations.Tables["Tests"].Columns["ID"],
_dsCombinations.Tables["DailyTotals"].Columns["ID"]);
later...
CurrencyManager myCurrencyManager =
(CurrencyManager)this.BindingContext["MyTestRelation"];
cast not valid
CurrencyManager myCurrencyManager =
(CurrencyManager)this.BindingContext["Tests.MyTestRelation"];
cast not valid

Thanks


"Nicholas Paldino [.NET/C# MVP]" <[email protected]>
wrote in message D,

Are you sure you are getting the correct currency mananger? When
you are getting the currency manager, you need to get the manager
which is returned to you by using the DataRelation as the key, not the
child data table (which is why the position is probably always zero).

Hope this helps.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

hi

I have a form with 2 datagrids showing related table data in a master
/ child or order / order details type relationship. I would like to
auto select the row in the order details table which contains the
highest priced item. My thoughts were to get the currency manager
from the orderdetails table and iterate thru each row and keep track
of the highest item and row and select that when done. I have found
that for some reason the currency manager of the order details table
is always a position 0 regardless of what is actually showing in the
order details datagrid.

What am I doing wrong?

Thanks !!
 
D,

Did you try looking in the debugger? Before you make the assignment,
paste:

this.BindingContext[_dsTests.Relations["MyTestRelation"]]

Into the watch window.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

D said:
I'm not sure where to look for that, I mean I catch the exception but I
don't see where it reads about the actual object. After reading MSDN a bit
I tried casting it to a propertymanager which workd but I'm not sure what
to do next. More reading I guess.

Any thoughts?

Thanks for your help.


Nicholas Paldino said:
D,

What is the type that is returned when you key on the relation? What
does the debugger tell you?


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

D said:
I'm afraid I'm still getting an invalid cast exception error when trying
to do

CurrencyManager myCurrencyManager =
(CurrencyManager)this.BindingContext[_dsTests.Relations["MyTestRelation"]];

I have a feeling that I'm going to have to get current id from the Tests
table and seek out the highest totals in the DailyTotals manually.


in message D,

Don't pass the string with the data relation name to the
BindingContext. Rather, pass the data relation itself, and you should
get it.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

I thought of that but I must have the syntax wrong because I'm getting
exceptions

_dsTests.Relations.Add("MyTestRelation",
_dsCombinations.Tables["Tests"].Columns["ID"],
_dsCombinations.Tables["DailyTotals"].Columns["ID"]);
later...
CurrencyManager myCurrencyManager =
(CurrencyManager)this.BindingContext["MyTestRelation"];
cast not valid
CurrencyManager myCurrencyManager =
(CurrencyManager)this.BindingContext["Tests.MyTestRelation"];
cast not valid

Thanks


"Nicholas Paldino [.NET/C# MVP]" <[email protected]>
wrote in message D,

Are you sure you are getting the correct currency mananger? When
you are getting the currency manager, you need to get the manager
which is returned to you by using the DataRelation as the key, not
the child data table (which is why the position is probably always
zero).

Hope this helps.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

hi

I have a form with 2 datagrids showing related table data in a
master / child or order / order details type relationship. I would
like to auto select the row in the order details table which
contains the highest priced item. My thoughts were to get the
currency manager from the orderdetails table and iterate thru each
row and keep track of the highest item and row and select that when
done. I have found that for some reason the currency manager of the
order details table is always a position 0 regardless of what is
actually showing in the order details datagrid.

What am I doing wrong?

Thanks !!
 
its propertymanager.

and its bindtype is DataRelation.


Nicholas Paldino said:
D,

Did you try looking in the debugger? Before you make the assignment,
paste:

this.BindingContext[_dsTests.Relations["MyTestRelation"]]

Into the watch window.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

D said:
I'm not sure where to look for that, I mean I catch the exception but I
don't see where it reads about the actual object. After reading MSDN a
bit I tried casting it to a propertymanager which workd but I'm not sure
what to do next. More reading I guess.

Any thoughts?

Thanks for your help.


Nicholas Paldino said:
D,

What is the type that is returned when you key on the relation? What
does the debugger tell you?


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

I'm afraid I'm still getting an invalid cast exception error when
trying to do

CurrencyManager myCurrencyManager =
(CurrencyManager)this.BindingContext[_dsTests.Relations["MyTestRelation"]];

I have a feeling that I'm going to have to get current id from the
Tests table and seek out the highest totals in the DailyTotals
manually.


"Nicholas Paldino [.NET/C# MVP]" <[email protected]>
wrote in message D,

Don't pass the string with the data relation name to the
BindingContext. Rather, pass the data relation itself, and you should
get it.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

I thought of that but I must have the syntax wrong because I'm getting
exceptions

_dsTests.Relations.Add("MyTestRelation",
_dsCombinations.Tables["Tests"].Columns["ID"],
_dsCombinations.Tables["DailyTotals"].Columns["ID"]);
later...
CurrencyManager myCurrencyManager =
(CurrencyManager)this.BindingContext["MyTestRelation"];
cast not valid
CurrencyManager myCurrencyManager =
(CurrencyManager)this.BindingContext["Tests.MyTestRelation"];
cast not valid

Thanks


"Nicholas Paldino [.NET/C# MVP]" <[email protected]>
wrote in message D,

Are you sure you are getting the correct currency mananger? When
you are getting the currency manager, you need to get the manager
which is returned to you by using the DataRelation as the key, not
the child data table (which is why the position is probably always
zero).

Hope this helps.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

hi

I have a form with 2 datagrids showing related table data in a
master / child or order / order details type relationship. I would
like to auto select the row in the order details table which
contains the highest priced item. My thoughts were to get the
currency manager from the orderdetails table and iterate thru each
row and keep track of the highest item and row and select that when
done. I have found that for some reason the currency manager of the
order details table is always a position 0 regardless of what is
actually showing in the order details datagrid.

What am I doing wrong?

Thanks !!
 
D,

That's not right then. What exactly is your data source? The property
manager is used when you bind to objects, not lists.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

D said:
its propertymanager.

and its bindtype is DataRelation.


Nicholas Paldino said:
D,

Did you try looking in the debugger? Before you make the assignment,
paste:

this.BindingContext[_dsTests.Relations["MyTestRelation"]]

Into the watch window.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

D said:
I'm not sure where to look for that, I mean I catch the exception but I
don't see where it reads about the actual object. After reading MSDN a
bit I tried casting it to a propertymanager which workd but I'm not sure
what to do next. More reading I guess.

Any thoughts?

Thanks for your help.


in message D,

What is the type that is returned when you key on the relation?
What does the debugger tell you?


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

I'm afraid I'm still getting an invalid cast exception error when
trying to do

CurrencyManager myCurrencyManager =
(CurrencyManager)this.BindingContext[_dsTests.Relations["MyTestRelation"]];

I have a feeling that I'm going to have to get current id from the
Tests table and seek out the highest totals in the DailyTotals
manually.


"Nicholas Paldino [.NET/C# MVP]" <[email protected]>
wrote in message D,

Don't pass the string with the data relation name to the
BindingContext. Rather, pass the data relation itself, and you should
get it.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

I thought of that but I must have the syntax wrong because I'm
getting exceptions

_dsTests.Relations.Add("MyTestRelation",
_dsCombinations.Tables["Tests"].Columns["ID"],
_dsCombinations.Tables["DailyTotals"].Columns["ID"]);
later...
CurrencyManager myCurrencyManager =
(CurrencyManager)this.BindingContext["MyTestRelation"];
cast not valid
CurrencyManager myCurrencyManager =
(CurrencyManager)this.BindingContext["Tests.MyTestRelation"];
cast not valid

Thanks


"Nicholas Paldino [.NET/C# MVP]" <[email protected]>
wrote in message D,

Are you sure you are getting the correct currency mananger?
When you are getting the currency manager, you need to get the
manager which is returned to you by using the DataRelation as the
key, not the child data table (which is why the position is
probably always zero).

Hope this helps.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

hi

I have a form with 2 datagrids showing related table data in a
master / child or order / order details type relationship. I would
like to auto select the row in the order details table which
contains the highest priced item. My thoughts were to get the
currency manager from the orderdetails table and iterate thru each
row and keep track of the highest item and row and select that
when done. I have found that for some reason the currency manager
of the order details table is always a position 0 regardless of
what is actually showing in the order details datagrid.

What am I doing wrong?

Thanks !!
 
My data source is a single dataset which I load 7 tables into from sql
server. This is during form_load and after loading the tables I create the
relations and then tie everything to different datagrids for display.

Later when I click on a row in the main grid that triggers a call to a
function where I am trying to determine the row select the row in the detals
table via the currencymanager.

do you have any articles or reference which I can look at to see other
examples of getting the currencymanger from a relation, I don't see any.

thanks


Nicholas Paldino said:
D,

That's not right then. What exactly is your data source? The property
manager is used when you bind to objects, not lists.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

D said:
its propertymanager.

and its bindtype is DataRelation.


Nicholas Paldino said:
D,

Did you try looking in the debugger? Before you make the assignment,
paste:

this.BindingContext[_dsTests.Relations["MyTestRelation"]]

Into the watch window.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

I'm not sure where to look for that, I mean I catch the exception but I
don't see where it reads about the actual object. After reading MSDN a
bit I tried casting it to a propertymanager which workd but I'm not
sure what to do next. More reading I guess.

Any thoughts?

Thanks for your help.


"Nicholas Paldino [.NET/C# MVP]" <[email protected]>
wrote in message D,

What is the type that is returned when you key on the relation?
What does the debugger tell you?


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

I'm afraid I'm still getting an invalid cast exception error when
trying to do

CurrencyManager myCurrencyManager =
(CurrencyManager)this.BindingContext[_dsTests.Relations["MyTestRelation"]];

I have a feeling that I'm going to have to get current id from the
Tests table and seek out the highest totals in the DailyTotals
manually.


"Nicholas Paldino [.NET/C# MVP]" <[email protected]>
wrote in message D,

Don't pass the string with the data relation name to the
BindingContext. Rather, pass the data relation itself, and you
should get it.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

I thought of that but I must have the syntax wrong because I'm
getting exceptions

_dsTests.Relations.Add("MyTestRelation",
_dsCombinations.Tables["Tests"].Columns["ID"],
_dsCombinations.Tables["DailyTotals"].Columns["ID"]);
later...
CurrencyManager myCurrencyManager =
(CurrencyManager)this.BindingContext["MyTestRelation"];
cast not valid
CurrencyManager myCurrencyManager =
(CurrencyManager)this.BindingContext["Tests.MyTestRelation"];
cast not valid

Thanks


"Nicholas Paldino [.NET/C# MVP]" <[email protected]>
wrote in message D,

Are you sure you are getting the correct currency mananger?
When you are getting the currency manager, you need to get the
manager which is returned to you by using the DataRelation as the
key, not the child data table (which is why the position is
probably always zero).

Hope this helps.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

hi

I have a form with 2 datagrids showing related table data in a
master / child or order / order details type relationship. I
would like to auto select the row in the order details table
which contains the highest priced item. My thoughts were to get
the currency manager from the orderdetails table and iterate thru
each row and keep track of the highest item and row and select
that when done. I have found that for some reason the currency
manager of the order details table is always a position 0
regardless of what is actually showing in the order details
datagrid.

What am I doing wrong?

Thanks !!
 

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

Back
Top