Respondido check if the current row is marked for delete

  • segunda-feira, 14 de maio de 2012 22:55
     
     

    I have a button on my grid that sets the status of a field in the entity to "Active".

    This works fine until I mark a record for delete with the standard delete control.

    Problem is that if I then click the button again I get an error.  So I need to check if the record is flagged as deleted and if so not try to activate it.

    Perhaps pop up a message instead.

    I can check for changes across the grid or on selected item but I want to know if the record is flagged for delete.

    How can I find this out?

    Gus

Todas as Respostas

  • terça-feira, 15 de maio de 2012 06:31
     
     Respondido

    You can use CanExecute method of button control:

    result = Products.SelectedItem != null && Products.SelectedItem.Details.EntityState != EntityState.Deleted;

    • Sugerido como Resposta Simon Jones [MSDL] terça-feira, 15 de maio de 2012 07:34
    • Marcado como Resposta GusBeare terça-feira, 15 de maio de 2012 07:53
    •  
  • terça-feira, 15 de maio de 2012 07:54
     
     

    many thanks ninoid!

    perfect and even greys out the activate button in the process!

    I spent ages trying to find an answer to that one..  really thought it must be simple!