Last post Feb 16, 2012 09:29 PM by Decker Dong - MSFT
Feb 15, 2012 07:20 AM|Yannick86|LINK
For my project multiple users could edit the same item at the same, but I want to implement something which will grant a first user to be able to edit the record, but as long as that user is working on the item which is related to that particular record
I want it to be locked so that when a second user tries to edit the item he'll get a popup saying the item is locked and that he'll have to wait.
First I was thinking I could do this by saving the record "Locked=True" when the first user opens the item and it gets unlocked when they save and exit the item, but of course there's the chance they just happen to close the browser. How would I catch this
The modifications to an item won't be a quick edit of one field, but a lot of work and a lot of child records will be linked to this one item so now I'm thinking of forcing the users to actually save & exit. In case they didn't they could see a list of items
which are locked by them and offer them the chance to release an item. Next to this an admin could release items that are locked by anyone.
What do you guys think?
Thanks in advance,
Feb 15, 2012 12:29 PM|tdykstra|LINK
The way you handle concurrency depends on the database access technology you are using. If you are using Entity Framework, see this tutorial:
It also explains some of the disadvantages of the locking approach you are thinking about.
Feb 16, 2012 04:33 AM|Yannick86|LINK
Thanks for your reply, but did you read my full post?
I don't think I'll need to handle concurrency like that if I do it the way I mentionned in my post, but I'm wondering what experience people have with this.
Feb 16, 2012 09:29 PM|decker dong - msft|LINK
To be honest，I'm afraid it's hard to control with that……because no one knows at which time who will begin to enter here to begin his/her first edition of the specific row，and because HTML is of no memoryable……So hard to control with server-side directly。
Maybe（If you are using DataSource，you can see this：Each record can be editted by one person：http://www.asp.net/web-forms/tutorials/data-access/accessing-the-database-directly-from-an-aspnet-page/implementing-optimistic-concurrency-with-the-sqldatasource-vb，this
seems like what you are asking……）