Urgent! Get rowindex - datagrid navigation

  • Thread starter m - team1 via DotNetMonster.com
  • Start date
M

m - team1 via DotNetMonster.com

hi everyone

ive written a huge unwieldy program for my company's annual maintenance
contract tracking! :) ok, my dataset has two relations : one table is called
AMC and is linked to AMC1. AMC1 in turn, is the parent table of AMC2. my
datagrid shows information only from AMC 1 and 2.

this is my problem:

when the user collapses a row in the datagrid, i need to know the exact row
index in the parent table so that i can see if the user can be permitted to
add a child row or not. (depends on the value of a particular column)

at the 11th hour ive discovered that datagrid.currentrowindex() just sets
arbit values - as in the row index is fine with respect to the datagrid - row
zero IS row zero. but currentrowindex doesnt tell me that the first row in
the datagrid is actually the 11th row, which is the critical information i
need!

im in dire straits - can someone please tell me how to get that information?
ive looked up most of the datagrid properties but i cant spot anything that
would help!

thanks!
 
B

Brian Tkatch

m said:
hi everyone

ive written a huge unwieldy program for my company's annual maintenance
contract tracking! :) ok, my dataset has two relations : one table is called
AMC and is linked to AMC1. AMC1 in turn, is the parent table of AMC2. my
datagrid shows information only from AMC 1 and 2.

this is my problem:

when the user collapses a row in the datagrid, i need to know the exact row
index in the parent table so that i can see if the user can be permitted to
add a child row or not. (depends on the value of a particular column)

at the 11th hour ive discovered that datagrid.currentrowindex() just sets
arbit values - as in the row index is fine with respect to the datagrid - row
zero IS row zero. but currentrowindex doesnt tell me that the first row in
the datagrid is actually the 11th row, which is the critical information i
need!

im in dire straits - can someone please tell me how to get that information?
ive looked up most of the datagrid properties but i cant spot anything that
would help!

thanks!
currentrowindex doesnt tell me that the first row in the datagrid is actually the 11th row

I think CurrentRowIndex would be what to use, but i do not understand
your issue here. What do you mean that the first is the eleventh?

B.
 
M

m - team1 via DotNetMonster.com

thanks for responding.

what i mean is that currentrowindex gives only the rowposition in the visible
rows - ie, for that particular grid view. its not the correct index number at
all. the row may be the first visible row, but its totally misleading in
terms of postiion in the dataset, which matters when it comes to edits, and
even more when it comes to deletions!!
 
R

raibeart

Your problm is that you are using something that you should not. You
need to use the primary key field value for the row, not the index for
the row.
 
B

Brian Tkatch

m said:
thanks for responding.

what i mean is that currentrowindex gives only the rowposition in the visible
rows - ie, for that particular grid view. its not the correct index number at
all. the row may be the first visible row, but its totally misleading in
terms of postiion in the dataset, which matters when it comes to edits, and
even more when it comes to deletions!!

True.

That's one of the next things i'll be dealing with on my project. :)

The DataGrid is not the DataTable, it is merely a window into the
DataTable's (default) DataView. Therefore, as the next poster pointed
out, you must use a PRIMARY KEY or some other form of identification on
UPDATE or DELETE.

If you add a DataAdaptor view the IDE, VB .NET will autogenerate code
for all four Commands in the DataAdaptor. It may be helpful to review
what they do, paying attention also to the RowVersion. Because the row
can be the original row, or the updated row (amongst others).

B.
 

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