Finding a DataRow index

  • Thread starter Thread starter William Ryan
  • Start date Start date
W

William Ryan

The datagrid has a CurrentCell property that gives you
both row and column information. As long as you don't
sort the grid, you can just check the currectcell and
you'll have the row index.

If you are sorting though, let me know and we can take a
different approach.

Good Luck,

Bill
 
Sorry Bill, maybe I didnt make myself clear on this one.

Assume you programatically create a new row by adding it to the table. When
the table is refilled by the dataadapter, the new row takes a new position
because it is being sorted by the persons name in th SQL select command.
(SELECT * FROM People ORDER By FirstName ).

Having found and preserved the new ID number using executescalar with a
MAX(ID) in the select statement, I can find the row created using the
Table.Find( ID ) method as I have a PKey on this table on column zero.
However I dont know what row position this is in the table so I dont know
how to select the newly created and corresponding row in the grid.

Hope you can shed some light on a way forward . . ., to me this seems like
an oversight, Ican locate the underying row using Grid.CurrentRowIndex but
cant datagrid.Select(row) because I dont know it .... see the dialema ?



--
Regards - One Handed Man

Author : Fish .NET & Keep .NET

==============================
 
OK. Thanks for your post. I took a look at it but unless i am missing
something ( and I probably am ), in order to find the row you need to sort
by index. Fine, but once you sort the position changes and hence you dont
know where the real position is on the datagrid which is what I need.



--
Regards - One Handed Man

Author : Fish .NET & Keep .NET

==============================
 
Back
Top