Mark,
I've been trying to figure out the same thing, and have
posted here before, but have not come up with a good
answer yet, other than looping through all the rows to
find a match.
I've played with hooking the ListChanged event on the
dataview, which returns the old and the new index of a
changed/added item in the list, but haven't found any
consistency in the results. Because the index of any/all
rows changes when you do an insert, you can get a lot of
events raised when you do a single insert. For example,
when you add an item to an unsorted list, you get a
single event with event-type "add" and the index where
you'd expect it (at the end). But, if you add to a
sorted list, in the cases I tried it added my new record
at the beginning (index 0), and then fired off more
events as it "moved" it into the right sorted position in
the list. As this move was happening, I'm not sure why I
didn't get even more events, as the indices of the other
items in the list had to have been changing around as
well. Finally, if the change you make to the list
entails wholesale changes to the indices in the list,
you'll get a single event type ("reset", I think) that
basically says the changes were so drastic that you
shouldn't bother looking at each event.
You'd think there'd be something like a "record id" which
doesn't change as you move things around, but I haven't
found it yet.
Also, if you don't mind sorting the dataview, you can use
myDataview.Find to find the index of your key. That's
probably more efficient than looping through the
collection of rows yourself, but I don't know. I'd sure
think there's a raw iteration of an unordered list
somewhere, rather than doing your own foreach, but I
haven't found it.
HTH,
Bill Borg