Original Value

Thread is closed for posting
4 posts, 0 answers
  1. Daniel
    Daniel avatar
    3 posts
    Member since:
    Sep 2008

    Posted 02 Nov 2009 Link to this post

    Hello
    how is it possible to access a field's original value?

    I've got a bound ComboBox on a Windows Form. After the SelectedIndexChanged event of the ComboBox fires, my code check's some business rules. In some cases the change of the field that is bound to the ComboBox need's to be canceled. Then the original value of the field, that the ComboBox is bound to, need's to be assigned again.

    Any ideas?

    Kind regards
    Mike
  2. PetarP
    Admin
    PetarP avatar
    754 posts

    Posted 05 Nov 2009 Link to this post

    Hi Daniel,

    You can subscribe to the IObjectScope Changing event. This even occurs when an persistent object is about to be changed. There you can perform your logic and if everything is fine you can allow the change to be done. If you, based on your business logic, decide that this change should not be done you can cancel the event by throwing an exception.
    static void Main(string[] args)
           {
               IObjectScope scope = ObjectScopeProvider1.GetNewObjectScope();
               scope.Tracking.Changing += new ChangeEventHandler(Tracking_Changing);
               scope.Transaction.Begin();
               //some action.
               scope.Transaction.Commit();
            
           }
     
           static void Tracking_Changing(object sender, ChangeEventArgs e)
           {
               //bussines logic goes here.
           }
    Note that you have access to the changed field via the OldValue property of the ChangeEventArgs.

    All the best,
    Petar
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  3. Daniel
    Daniel avatar
    3 posts
    Member since:
    Sep 2008

    Posted 12 Nov 2009 Link to this post

    Hi Petar
    thank you very much!

    Is there no other way to access the original value? I don't want to track, the change of an object. I want to access the original value of an object any time in my code.

    Kind regards
    Mike
  4. PetarP
    Admin
    PetarP avatar
    754 posts

    Posted 13 Nov 2009 Link to this post

    Hi Daniel,

    I am afraid but currently there is no other way to access the original value of an object but to track its changes. We are sorry for any inconvenience this might be causing.

    Sincerely yours,
    Petar
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Back to Top