LightSwitch Updating of 2 changed records in the DataGrid, that is part of a modal dialog does not work as expected. RRS feed

  • Question

  • Hi LightSwitch Team,

    I have a modal dialog that has a DataGrid with records. Changes of records into the DataGrid will be save by clicking on OK-Button and if the validation was successfully.
    So, let say that 2 records of DataGrid will be changed: first will be updated and the second record will be inserted.
    After operation has finished, I have a wrong value of a property of an another entity, that will be refresh within this 2 methods.

    By debuging, I can see, that by call of DataWorkspace.ApplicationData.SaveChanges() the method Entity_Inserted(Entity entity) will be called first and after that the method Entity_Updated(Entity entity).

    Please, how can I do, to have correct refreshed value of the entity, that will be refreshed withhin this 2 methods?

    Many, many thanks.

    Thursday, April 10, 2014 9:36 PM

All replies

  • Hi AndySta,

    I didn't quite understand your question perfectly but I wanted to explain something as I think it may be where your problem lies.

    If you add code to the Inserted method this will then trigger the Updating and Updated methods as it's after the record was initially saved. If you try putting the code in the Inserting method this will stop the application triggering the Updating and Updated methods.

    I hope that makes sense and helps you with your situation.


    Thursday, April 10, 2014 9:42 PM
  • Hi Paul,

    first at all many thank you for the prompt reply.

    I put the code to the Inserting method. While debuging I saw, that Inserting trigger the Updating method.

    As I related above, I have 2 records (1st was updated, 2nd was inserted) into the DataGrid (included into a modal Dialog). After clicking OK-Button into the modal dialog (with saving) the order of calls are: Inserting -> Updating -> Inserted -> Updated.

    Friday, April 11, 2014 9:49 AM