0

In asp.net for Gridview, how to avoid optimistic concurrency ? How the user to restrict not to edit when already the record is in edit mode ?

4

1 回答 1

0

to check if the data changed clientside:

I would suggest a TextBox which contains the Information and the same TextBox as "css: visibility:hidden" and readonly containing the original Information. then you can always check on clientside with JavaScript if the user changed the value of the TextBox without doing a postback to the Server.

to lock the users edit:

its difficult on asp to manage this cause the communication is an asyncronious way. you can for example add a new column in your databasetable "locked"(bit) and can lock the dataset if someone enters the editmode. then you can check the locked value from some other user and restrict the edit mode for him. (care about sessions running out and so on; maybe use an timestamp as lock and open the lock after the sessionminutes expired).

if the user is in edit mode alrdy:

you cant lock him (if your not doing postbacks to the Server and asking him for the lock in intervals (would be done my AJAX)). You only can check the locked value when he tries to save his changes. But this is to late cause he alrdy changed some values and they will get reverted. Maybe you can ask him if you can see the values changed in the database if he wants to overwrite those changes.

hope this helps, noone

于 2013-02-15T10:17:43.243 回答