I have griview with all functionalities like Insert/Delete/Update and Cancel the records. No two users should manipulate(Insert/Delete/Update and Cancel) the records at the same time. With C# Code-Behind how to achive this. Please suggest me.
Optimistic concurrency is for detecting things like this. To really make it impossible, you would have to write your own locking mechanism. However, due to the unpredictable nature of web interfaces, it is hard to get this working well. (A user can close
a browser while editing a record. How to get rid of the lock then?)
Superguppie.
Please remember to click “Mark as Answer” on the post that helps you. This can be beneficial to other community members reading the thread.
When all you've got is a Hammer, Every Problem looks like a Nail. Michael Swain.
Thanks for the replies. I have implemented optimistic concurrency. Anyhow as you said how to avoid such scenarios like closing the browser while editing a record. Any ideas please.
With optimistic concurrency, there should not be a problem. Whenever a user edits something someone else has already edited, this will be detected upon update. Then a proper response can be done. (Like resolving the differences.)
For locking, locks are typically deleted after a certain timeout. The period will have to be long enough for an actual edit, but not too long to keep the record locked. (Anyone who wants to edit a record that is already locked will not be able to do so.)
You could make the period shorter by putting an UpdatePanel with a Timer in your page. Give the timer a period like 5 seconds. In the Tick handler, keep the lock alive. When the browsers is closed, the lock won't be kept alive.
Superguppie.
Please remember to click “Mark as Answer” on the post that helps you. This can be beneficial to other community members reading the thread.
When all you've got is a Hammer, Every Problem looks like a Nail. Michael Swain.
sayedaly
Member
71 Points
79 Posts
Avoiding users to Insert/Delete/Update and Cancel records to gridview at same time
Jul 04, 2012 11:15 AM|LINK
Hi All,
I have griview with all functionalities like Insert/Delete/Update and Cancel the records. No two users should manipulate(Insert/Delete/Update and Cancel) the records at the same time. With C# Code-Behind how to achive this. Please suggest me.
Thanks,
-Sayed Ali
Basquiat
Contributor
2604 Points
743 Posts
Re: Avoiding users to Insert/Delete/Update and Cancel records to gridview at same time
Jul 04, 2012 12:12 PM|LINK
Hi
Configure the Gridview's datasource. Select the "Advanced" button and then tick "Use optimistic concurrency"
Krishna Pram...
Member
73 Points
41 Posts
Re: Avoiding users to Insert/Delete/Update and Cancel records to gridview at same time
Jul 04, 2012 06:15 PM|LINK
There is no need of writing c# code you can achieve this using optimistic concurrency selected in the advanced while configuring data source
hafizzeeshan
Participant
834 Points
253 Posts
Re: Avoiding users to Insert/Delete/Update and Cancel records to gridview at same time
Jul 05, 2012 05:08 AM|LINK
Hi
Check it, i hope it will work for uu
http://www.asp.net/web-forms/tutorials/data-access/editing,-inserting,-and-deleting-data/implementing-optimistic-concurrency-cs
Regards
Zeeshan
Zeeshan Rauf
# 92-3216698206
Email : zeeshan_rouf@hotmail.com
Please mark the replies as answers if they help or unmark if not.
superguppie
All-Star
48225 Points
8679 Posts
Re: Avoiding users to Insert/Delete/Update and Cancel records to gridview at same time
Jul 09, 2012 12:16 PM|LINK
Optimistic concurrency is for detecting things like this. To really make it impossible, you would have to write your own locking mechanism. However, due to the unpredictable nature of web interfaces, it is hard to get this working well. (A user can close a browser while editing a record. How to get rid of the lock then?)
Please remember to click “Mark as Answer” on the post that helps you. This can be beneficial to other community members reading the thread.
When all you've got is a Hammer, Every Problem looks like a Nail. Michael Swain.
sayedaly
Member
71 Points
79 Posts
Re: Avoiding users to Insert/Delete/Update and Cancel records to gridview at same time
Jul 10, 2012 06:21 AM|LINK
Thanks for the replies. I have implemented optimistic concurrency. Anyhow as you said how to avoid such scenarios like closing the browser while editing a record. Any ideas please.
superguppie
All-Star
48225 Points
8679 Posts
Re: Avoiding users to Insert/Delete/Update and Cancel records to gridview at same time
Jul 13, 2012 01:00 PM|LINK
With optimistic concurrency, there should not be a problem. Whenever a user edits something someone else has already edited, this will be detected upon update. Then a proper response can be done. (Like resolving the differences.)
For locking, locks are typically deleted after a certain timeout. The period will have to be long enough for an actual edit, but not too long to keep the record locked. (Anyone who wants to edit a record that is already locked will not be able to do so.)
You could make the period shorter by putting an UpdatePanel with a Timer in your page. Give the timer a period like 5 seconds. In the Tick handler, keep the lock alive. When the browsers is closed, the lock won't be kept alive.
Please remember to click “Mark as Answer” on the post that helps you. This can be beneficial to other community members reading the thread.
When all you've got is a Hammer, Every Problem looks like a Nail. Michael Swain.