tags:

views:

29

answers:

2

I have a form in which we are showing customer records in a grid.User clicks a row, and in a new form record is shown.After editing some values, user may click cancel. if so, in grid we need to return to original values.

How can I restore the original state of the entity.We are using linq-to-sql, and grid is bounded to List.One way I see is,using getoriginalentitystate method.

A: 

As the user is entering data in the form, the values should be stored in your UI layer (not written to your "database"). The data in the form is held there temporarily until the user clicks 'OK'/commit. If the user clicks 'cancel' the form is simply discarded and not written to the database.

Until the user hits 'OK', the original data is still in the database. You can get the original values there.

Robert Cartaino
+1  A: 

If a user cancels a process, no change is made at the Database and the control reverts back to the pre-action state. This is a normal and built-in behaviour.

In case, if this is not happening, try rebinding List to it's DataSource, like

myList.Databind()
Asad Butt