By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,319 Members | 1,963 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,319 IT Pros & Developers. It's quick & easy.

Retrieving Value from Grid in Master Detail Relationship

P: n/a
I'm having the hardest time doing the simplest thing.

I have a DataGrid bound to a table in a master detail DataRelation within a
DataSet

relTaskActivities = new DataRelation("TaskActivities", parentCol, childCol);
dsTaskActivities.Relations.Add(relTaskActivities);
dgActivity.SetDataBinding(dsTaskActivities, "Tasks.TaskActivities");

This works fine. I have a properly behaving master detail relationship.
But now I need to retrieve the value of a specific column in the current row
(the one selected by the user) from the detail side. I've created a
CurrencyManager to obtain the row:

cActivityMgr = (CurrencyManager)this.BindingContext[dsTaskActivities,
"Tasks.TaskActivities"];

And I've used it to select the current row:
int ThisRow = cActivityMgr.Position;
string richNote =
dsTaskActivities.Tables["Activity"].Rows[ThisRow]["Note"].ToString();

I'm getting the contents of the desired column but not the current row. It
appears to be selecting the row without regard to the master detail
relationship. How do I get the proper index of the selected row within the
grid?

Thanks.
Nov 17 '05 #1
Share this Question
Share on Google+
8 Replies


P: n/a
Hi,
inline

"Christopher Weaver" <we*****@nospamverizon.net> wrote in message
news:OA**************@TK2MSFTNGP12.phx.gbl...
I'm having the hardest time doing the simplest thing.

I have a DataGrid bound to a table in a master detail DataRelation within
a DataSet

relTaskActivities = new DataRelation("TaskActivities", parentCol,
childCol);
dsTaskActivities.Relations.Add(relTaskActivities);
dgActivity.SetDataBinding(dsTaskActivities, "Tasks.TaskActivities");

This works fine. I have a properly behaving master detail relationship.
But now I need to retrieve the value of a specific column in the current
row (the one selected by the user) from the detail side. I've created a
CurrencyManager to obtain the row:

cActivityMgr = (CurrencyManager)this.BindingContext[dsTaskActivities,
"Tasks.TaskActivities"];

And I've used it to select the current row:
int ThisRow = cActivityMgr.Position;
string richNote =
dsTaskActivities.Tables["Activity"].Rows[ThisRow]["Note"].ToString();
You can get the selected row (DataRowView) directly from the CurrencyManager
:

DataRowView activityDRV =
(DataRowView)this.BindingContext[dsTaskActivities,
"Tasks.TaskActivities"].Current;

string richNote = (string)activityDRV["Note"];
HTH,
greeetings

I'm getting the contents of the desired column but not the current row.
It appears to be selecting the row without regard to the master detail
relationship. How do I get the proper index of the selected row within
the grid?

Thanks.

Nov 17 '05 #2

P: n/a
Hi,
inline

"Christopher Weaver" <we*****@nospamverizon.net> wrote in message
news:OA**************@TK2MSFTNGP12.phx.gbl...
I'm having the hardest time doing the simplest thing.

I have a DataGrid bound to a table in a master detail DataRelation within
a DataSet

relTaskActivities = new DataRelation("TaskActivities", parentCol,
childCol);
dsTaskActivities.Relations.Add(relTaskActivities);
dgActivity.SetDataBinding(dsTaskActivities, "Tasks.TaskActivities");

This works fine. I have a properly behaving master detail relationship.
But now I need to retrieve the value of a specific column in the current
row (the one selected by the user) from the detail side. I've created a
CurrencyManager to obtain the row:

cActivityMgr = (CurrencyManager)this.BindingContext[dsTaskActivities,
"Tasks.TaskActivities"];

And I've used it to select the current row:
int ThisRow = cActivityMgr.Position;
string richNote =
dsTaskActivities.Tables["Activity"].Rows[ThisRow]["Note"].ToString();
You can get the selected row (DataRowView) directly from the CurrencyManager
:

DataRowView activityDRV =
(DataRowView)this.BindingContext[dsTaskActivities,
"Tasks.TaskActivities"].Current;

string richNote = (string)activityDRV["Note"];
HTH,
greeetings

I'm getting the contents of the desired column but not the current row.
It appears to be selecting the row without regard to the master detail
relationship. How do I get the proper index of the selected row within
the grid?

Thanks.

Nov 17 '05 #3

P: n/a
Thanks for writing back, but I must say that I've never read a more terse or
vague response. Nevertheless, I scratched my head for a while a concluded
that the only possible meaning that I could attribute to your answer in the
context of my question was that the grid itself must have the properties I'm
looking for.

I looked again at the DataGrid in the help system and realized that I had
been looking at the wrong entry. What a difference a few properties can
make.

For anyone listening in the working code looks like this:

int ThisRow = dgActivity.CurrentRowIndex;
string richNote = dgActivity[ThisRow, 1].ToString();

Where 1 is the index of the column I'm looking for.


"Bart Mermuys" <bm*************@hotmail.com> wrote in message
news:%2****************@TK2MSFTNGP14.phx.gbl...
Hi,
inline

"Christopher Weaver" <we*****@nospamverizon.net> wrote in message
news:OA**************@TK2MSFTNGP12.phx.gbl...
I'm having the hardest time doing the simplest thing.

I have a DataGrid bound to a table in a master detail DataRelation within
a DataSet

relTaskActivities = new DataRelation("TaskActivities", parentCol,
childCol);
dsTaskActivities.Relations.Add(relTaskActivities);
dgActivity.SetDataBinding(dsTaskActivities, "Tasks.TaskActivities");

This works fine. I have a properly behaving master detail relationship.
But now I need to retrieve the value of a specific column in the current
row (the one selected by the user) from the detail side. I've created a
CurrencyManager to obtain the row:

cActivityMgr = (CurrencyManager)this.BindingContext[dsTaskActivities,
"Tasks.TaskActivities"];

And I've used it to select the current row:
int ThisRow = cActivityMgr.Position;
string richNote =
dsTaskActivities.Tables["Activity"].Rows[ThisRow]["Note"].ToString();


You can get the selected row (DataRowView) directly from the
CurrencyManager :

DataRowView activityDRV =
(DataRowView)this.BindingContext[dsTaskActivities,
"Tasks.TaskActivities"].Current;

string richNote = (string)activityDRV["Note"];
HTH,
greeetings

I'm getting the contents of the desired column but not the current row.
It appears to be selecting the row without regard to the master detail
relationship. How do I get the proper index of the selected row within
the grid?

Thanks.


Nov 17 '05 #4

P: n/a
Thanks for writing back, but I must say that I've never read a more terse or
vague response. Nevertheless, I scratched my head for a while a concluded
that the only possible meaning that I could attribute to your answer in the
context of my question was that the grid itself must have the properties I'm
looking for.

I looked again at the DataGrid in the help system and realized that I had
been looking at the wrong entry. What a difference a few properties can
make.

For anyone listening in the working code looks like this:

int ThisRow = dgActivity.CurrentRowIndex;
string richNote = dgActivity[ThisRow, 1].ToString();

Where 1 is the index of the column I'm looking for.


"Bart Mermuys" <bm*************@hotmail.com> wrote in message
news:%2****************@TK2MSFTNGP14.phx.gbl...
Hi,
inline

"Christopher Weaver" <we*****@nospamverizon.net> wrote in message
news:OA**************@TK2MSFTNGP12.phx.gbl...
I'm having the hardest time doing the simplest thing.

I have a DataGrid bound to a table in a master detail DataRelation within
a DataSet

relTaskActivities = new DataRelation("TaskActivities", parentCol,
childCol);
dsTaskActivities.Relations.Add(relTaskActivities);
dgActivity.SetDataBinding(dsTaskActivities, "Tasks.TaskActivities");

This works fine. I have a properly behaving master detail relationship.
But now I need to retrieve the value of a specific column in the current
row (the one selected by the user) from the detail side. I've created a
CurrencyManager to obtain the row:

cActivityMgr = (CurrencyManager)this.BindingContext[dsTaskActivities,
"Tasks.TaskActivities"];

And I've used it to select the current row:
int ThisRow = cActivityMgr.Position;
string richNote =
dsTaskActivities.Tables["Activity"].Rows[ThisRow]["Note"].ToString();


You can get the selected row (DataRowView) directly from the
CurrencyManager :

DataRowView activityDRV =
(DataRowView)this.BindingContext[dsTaskActivities,
"Tasks.TaskActivities"].Current;

string richNote = (string)activityDRV["Note"];
HTH,
greeetings

I'm getting the contents of the desired column but not the current row.
It appears to be selecting the row without regard to the master detail
relationship. How do I get the proper index of the selected row within
the grid?

Thanks.


Nov 17 '05 #5

P: n/a
Hi,

"Christopher Weaver" <we*****@nospamverizon.net> wrote in message
news:uC**************@TK2MSFTNGP10.phx.gbl...
Thanks for writing back, but I must say that I've never read a more terse
or vague response.
What's so vague about it, i mean you yourself said you can get the position
out of a CurrencyManager, but the position didn't match the DataTable,
because a grid is never directly bound to a DataTable or DataSet but to a
DataView.

Then i said, you can directly get the current DataRowView from the
CurrencyManager like this:

DataRowView activityDRV =
(DataRowView)this.BindingContext[dsTaskActivities,
"Tasks.TaskActivities"].Current;

Once you have the current DataRowView you can get the value for an
individual cell, like:

string richNote = (string)activityDRV["Note"];

I don't know what more i could have told you.
Nevertheless, I scratched my head for a while a concluded that the only
possible meaning that I could attribute to your answer in the context of my
question was that the grid itself must have the properties I'm looking for.
Really ? All i said was that the CurrencyManager keeps the current row
which happens to be a DataRowView.

I looked again at the DataGrid in the help system and realized that I had
been looking at the wrong entry. What a difference a few properties can
make.

For anyone listening in the working code looks like this:

int ThisRow = dgActivity.CurrentRowIndex;
string richNote = dgActivity[ThisRow, 1].ToString();
The way i showed you works, but if you prefer the above, no problem, it's
just another way.


Where 1 is the index of the column I'm looking for.


"Bart Mermuys" <bm*************@hotmail.com> wrote in message
news:%2****************@TK2MSFTNGP14.phx.gbl...
Hi,
inline

"Christopher Weaver" <we*****@nospamverizon.net> wrote in message
news:OA**************@TK2MSFTNGP12.phx.gbl...
I'm having the hardest time doing the simplest thing.

I have a DataGrid bound to a table in a master detail DataRelation
within a DataSet

relTaskActivities = new DataRelation("TaskActivities", parentCol,
childCol);
dsTaskActivities.Relations.Add(relTaskActivities);
dgActivity.SetDataBinding(dsTaskActivities, "Tasks.TaskActivities");

This works fine. I have a properly behaving master detail relationship.
But now I need to retrieve the value of a specific column in the current
row (the one selected by the user) from the detail side. I've created a
CurrencyManager to obtain the row:

cActivityMgr = (CurrencyManager)this.BindingContext[dsTaskActivities,
"Tasks.TaskActivities"];

And I've used it to select the current row:
int ThisRow = cActivityMgr.Position;
string richNote =
dsTaskActivities.Tables["Activity"].Rows[ThisRow]["Note"].ToString();


You can get the selected row (DataRowView) directly from the
CurrencyManager :

DataRowView activityDRV =
(DataRowView)this.BindingContext[dsTaskActivities,
"Tasks.TaskActivities"].Current;

string richNote = (string)activityDRV["Note"];
HTH,
greeetings

I'm getting the contents of the desired column but not the current row.
It appears to be selecting the row without regard to the master detail
relationship. How do I get the proper index of the selected row within
the grid?

Thanks.



Nov 17 '05 #6

P: n/a
Hi,

"Christopher Weaver" <we*****@nospamverizon.net> wrote in message
news:uC**************@TK2MSFTNGP10.phx.gbl...
Thanks for writing back, but I must say that I've never read a more terse
or vague response.
What's so vague about it, i mean you yourself said you can get the position
out of a CurrencyManager, but the position didn't match the DataTable,
because a grid is never directly bound to a DataTable or DataSet but to a
DataView.

Then i said, you can directly get the current DataRowView from the
CurrencyManager like this:

DataRowView activityDRV =
(DataRowView)this.BindingContext[dsTaskActivities,
"Tasks.TaskActivities"].Current;

Once you have the current DataRowView you can get the value for an
individual cell, like:

string richNote = (string)activityDRV["Note"];

I don't know what more i could have told you.
Nevertheless, I scratched my head for a while a concluded that the only
possible meaning that I could attribute to your answer in the context of my
question was that the grid itself must have the properties I'm looking for.
Really ? All i said was that the CurrencyManager keeps the current row
which happens to be a DataRowView.

I looked again at the DataGrid in the help system and realized that I had
been looking at the wrong entry. What a difference a few properties can
make.

For anyone listening in the working code looks like this:

int ThisRow = dgActivity.CurrentRowIndex;
string richNote = dgActivity[ThisRow, 1].ToString();
The way i showed you works, but if you prefer the above, no problem, it's
just another way.


Where 1 is the index of the column I'm looking for.


"Bart Mermuys" <bm*************@hotmail.com> wrote in message
news:%2****************@TK2MSFTNGP14.phx.gbl...
Hi,
inline

"Christopher Weaver" <we*****@nospamverizon.net> wrote in message
news:OA**************@TK2MSFTNGP12.phx.gbl...
I'm having the hardest time doing the simplest thing.

I have a DataGrid bound to a table in a master detail DataRelation
within a DataSet

relTaskActivities = new DataRelation("TaskActivities", parentCol,
childCol);
dsTaskActivities.Relations.Add(relTaskActivities);
dgActivity.SetDataBinding(dsTaskActivities, "Tasks.TaskActivities");

This works fine. I have a properly behaving master detail relationship.
But now I need to retrieve the value of a specific column in the current
row (the one selected by the user) from the detail side. I've created a
CurrencyManager to obtain the row:

cActivityMgr = (CurrencyManager)this.BindingContext[dsTaskActivities,
"Tasks.TaskActivities"];

And I've used it to select the current row:
int ThisRow = cActivityMgr.Position;
string richNote =
dsTaskActivities.Tables["Activity"].Rows[ThisRow]["Note"].ToString();


You can get the selected row (DataRowView) directly from the
CurrencyManager :

DataRowView activityDRV =
(DataRowView)this.BindingContext[dsTaskActivities,
"Tasks.TaskActivities"].Current;

string richNote = (string)activityDRV["Note"];
HTH,
greeetings

I'm getting the contents of the desired column but not the current row.
It appears to be selecting the row without regard to the master detail
relationship. How do I get the proper index of the selected row within
the grid?

Thanks.



Nov 17 '05 #7

P: n/a
My Dear Friend,

I am laughing out loud right now. I didn't read your entire post! At the
top you wrote 'Hi, inline.' and I took that to be your response --- all of
your response.

Having just read the rest of what you posted, I must say there was nothing
vague about it at all. Thank you again for your help! And I promise to
never fail to read an entire post!

Christopher Weaver


"Bart Mermuys" <bm*************@hotmail.com> wrote in message
news:Of**************@TK2MSFTNGP14.phx.gbl...
Hi,

"Christopher Weaver" <we*****@nospamverizon.net> wrote in message
news:uC**************@TK2MSFTNGP10.phx.gbl...
Thanks for writing back, but I must say that I've never read a more terse
or vague response.


What's so vague about it, i mean you yourself said you can get the
position out of a CurrencyManager, but the position didn't match the
DataTable, because a grid is never directly bound to a DataTable or
DataSet but to a DataView.

Then i said, you can directly get the current DataRowView from the
CurrencyManager like this:

DataRowView activityDRV =
(DataRowView)this.BindingContext[dsTaskActivities,
"Tasks.TaskActivities"].Current;

Once you have the current DataRowView you can get the value for an
individual cell, like:

string richNote = (string)activityDRV["Note"];

I don't know what more i could have told you.
Nevertheless, I scratched my head for a while a concluded that the only
possible meaning that I could attribute to your answer in the context of
my question was that the grid itself must have the properties I'm looking
for.


Really ? All i said was that the CurrencyManager keeps the current row
which happens to be a DataRowView.

I looked again at the DataGrid in the help system and realized that I had
been looking at the wrong entry. What a difference a few properties can
make.

For anyone listening in the working code looks like this:

int ThisRow = dgActivity.CurrentRowIndex;
string richNote = dgActivity[ThisRow, 1].ToString();


The way i showed you works, but if you prefer the above, no problem, it's
just another way.


Where 1 is the index of the column I'm looking for.


"Bart Mermuys" <bm*************@hotmail.com> wrote in message
news:%2****************@TK2MSFTNGP14.phx.gbl...
Hi,
inline

"Christopher Weaver" <we*****@nospamverizon.net> wrote in message
news:OA**************@TK2MSFTNGP12.phx.gbl...
I'm having the hardest time doing the simplest thing.

I have a DataGrid bound to a table in a master detail DataRelation
within a DataSet

relTaskActivities = new DataRelation("TaskActivities", parentCol,
childCol);
dsTaskActivities.Relations.Add(relTaskActivities);
dgActivity.SetDataBinding(dsTaskActivities, "Tasks.TaskActivities");

This works fine. I have a properly behaving master detail
relationship. But now I need to retrieve the value of a specific column
in the current row (the one selected by the user) from the detail side.
I've created a CurrencyManager to obtain the row:

cActivityMgr = (CurrencyManager)this.BindingContext[dsTaskActivities,
"Tasks.TaskActivities"];

And I've used it to select the current row:
int ThisRow = cActivityMgr.Position;
string richNote =
dsTaskActivities.Tables["Activity"].Rows[ThisRow]["Note"].ToString();

You can get the selected row (DataRowView) directly from the
CurrencyManager :

DataRowView activityDRV =
(DataRowView)this.BindingContext[dsTaskActivities,
"Tasks.TaskActivities"].Current;

string richNote = (string)activityDRV["Note"];
HTH,
greeetings
I'm getting the contents of the desired column but not the current row.
It appears to be selecting the row without regard to the master detail
relationship. How do I get the proper index of the selected row within
the grid?

Thanks.



Nov 17 '05 #8

P: n/a
Hi,

"Christopher Weaver" <we*****@nospamverizon.net> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
My Dear Friend,

I am laughing out loud right now. I didn't read your entire post! At the
top you wrote 'Hi, inline.' and I took that to be your response --- all of
your response.
Yeah that's funny, I can imagine that if you only read "inline" that it was
extremely vague :)

Having just read the rest of what you posted, I must say there was nothing
vague about it at all. Thank you again for your help! And I promise to
never fail to read an entire post!
Fair enough.

Greetings

Christopher Weaver


"Bart Mermuys" <bm*************@hotmail.com> wrote in message
news:Of**************@TK2MSFTNGP14.phx.gbl...
Hi,

"Christopher Weaver" <we*****@nospamverizon.net> wrote in message
news:uC**************@TK2MSFTNGP10.phx.gbl...
Thanks for writing back, but I must say that I've never read a more
terse or vague response.


What's so vague about it, i mean you yourself said you can get the
position out of a CurrencyManager, but the position didn't match the
DataTable, because a grid is never directly bound to a DataTable or
DataSet but to a DataView.

Then i said, you can directly get the current DataRowView from the
CurrencyManager like this:

DataRowView activityDRV =
(DataRowView)this.BindingContext[dsTaskActivities,
"Tasks.TaskActivities"].Current;

Once you have the current DataRowView you can get the value for an
individual cell, like:

string richNote = (string)activityDRV["Note"];

I don't know what more i could have told you.
Nevertheless, I scratched my head for a while a concluded that the only
possible meaning that I could attribute to your answer in the context of
my question was that the grid itself must have the properties I'm looking
for.


Really ? All i said was that the CurrencyManager keeps the current row
which happens to be a DataRowView.

I looked again at the DataGrid in the help system and realized that I
had been looking at the wrong entry. What a difference a few properties
can make.

For anyone listening in the working code looks like this:

int ThisRow = dgActivity.CurrentRowIndex;
string richNote = dgActivity[ThisRow, 1].ToString();


The way i showed you works, but if you prefer the above, no problem, it's
just another way.


Where 1 is the index of the column I'm looking for.


"Bart Mermuys" <bm*************@hotmail.com> wrote in message
news:%2****************@TK2MSFTNGP14.phx.gbl...
Hi,
inline

"Christopher Weaver" <we*****@nospamverizon.net> wrote in message
news:OA**************@TK2MSFTNGP12.phx.gbl...
> I'm having the hardest time doing the simplest thing.
>
> I have a DataGrid bound to a table in a master detail DataRelation
> within a DataSet
>
> relTaskActivities = new DataRelation("TaskActivities", parentCol,
> childCol);
> dsTaskActivities.Relations.Add(relTaskActivities);
> dgActivity.SetDataBinding(dsTaskActivities, "Tasks.TaskActivities");
>
> This works fine. I have a properly behaving master detail
> relationship. But now I need to retrieve the value of a specific
> column in the current row (the one selected by the user) from the
> detail side. I've created a CurrencyManager to obtain the row:
>
> cActivityMgr = (CurrencyManager)this.BindingContext[dsTaskActivities,
> "Tasks.TaskActivities"];
>
> And I've used it to select the current row:
> int ThisRow = cActivityMgr.Position;
> string richNote =
> dsTaskActivities.Tables["Activity"].Rows[ThisRow]["Note"].ToString();

You can get the selected row (DataRowView) directly from the
CurrencyManager :

DataRowView activityDRV =
(DataRowView)this.BindingContext[dsTaskActivities,
"Tasks.TaskActivities"].Current;

string richNote = (string)activityDRV["Note"];
HTH,
greeetings

>
> I'm getting the contents of the desired column but not the current
> row. It appears to be selecting the row without regard to the master
> detail relationship. How do I get the proper index of the selected
> row within the grid?
>
> Thanks.
>



Nov 17 '05 #9

This discussion thread is closed

Replies have been disabled for this discussion.