Use ViewModel<T> Save Method, the Model Rebind.

Use ViewModel<T> Save Method, the Model Rebind.

Old forum URL: forums.lhotka.net/forums/t/10655.aspx


simon posted on Tuesday, August 30, 2011

If invoke the method save of ViewMode<T>, the UI will rebind to the BO.  if the T is BLB ,  i don't want the user to find the new or just edited row  after click the save button. 

but i override the method Save as below:

   public override void Save(object sender, ExecuteEventArgs e)

        {

            Model.ApplyEdit();

            Model.Save(); 

        }

but the UI can't refresh. and continue to add new row and click save, will popup a error:Edit level mismatch in AcceptChanges

how can i do?

RockfordLhotka replied on Tuesday, August 30, 2011

You must remember that the save operation returns a new object. This is why the rebind occurs - because there's a whole new object to which the UI must bind.

There are a couple options. One is to use a dynamic list, so each individual row is saved as the user leaves the row. Another is to use a diffgram technique to save the changed data, without moving the object graph to the app server and back (theres a sample in the Samples download that demonstrates this).

Copyright (c) Marimer LLC