Link to home
Start Free TrialLog in
Avatar of PiedBird
PiedBird

asked on

DataGridview: re select previously selected row after datasource refreshed

G'day
What's your favourite procedure for this simple task?
ASKER CERTIFIED SOLUTION
Avatar of appari
appari
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of PiedBird
PiedBird

ASKER

appari
thanks, Nearly works.
I select a record on my dgv and open form in dialog to edit data. If I don't make any changes your code runs fine after the dialog form closes but if I edit the dialog form there is a problem.

when I call:
Me.SaleDetailsTableAdapter.Update(Me.DsTransaction.SaleDetails)   'in dialog form

I get this error:
Concurrency violation: the UpdateCommand affected 0 of the expected 1 records.

I don't know anything about your Dim curPosCurManager As CurrencyManager. Guess I better do some reading.

appari:
bare with me.
I think your code is probably not the cause of update problem. I seem to have made something very like an intermittent fault.... which isn't possible.
I'll be back soon.
I thought this would be easy! Appari I again suspect my database some how thinks your code wants to update the same record as my dialog form. I think it (the database) was disturbed also by my readonly datagridview too but we seem to have overcome that.

Can I perhaps tell the database to ignore any other edits pending (this is a single user database anyway) when I call the update method of the table adapter on the dialog form? What code would do this?

I'm sorry if I have gone completely off track. Am trying to understand with insufficient mental resources!
what happens if you comment out the code i have provided? does it update without any errors?
the code i posted wont update anything its just reading the current position from the bound datasource.
can you post the existing code
I just commented out your code and got the update method to fail without it. Believe me this was the approach I was taking already but the method doesn't fail every time. I've got to work out what it is that makes the database think there is two edits to consider while I only know of one. I'll give you points on this question and open another on the concurrency problem. Hope you can have a look. Thanks.