Print Page | Close Window

Checking previous values of properties

Printed From: IdeaBlade
Category: DevForce
Forum Name: DevForce Classic
Forum Discription: For .NET 2.0
URL: http://www.ideablade.com/forum/forum_posts.asp?TID=808
Printed Date: 11-Jun-2026 at 3:11am


Topic: Checking previous values of properties
Posted By: BillG
Subject: Checking previous values of properties
Date Posted: 15-May-2008 at 10:30pm
When I am about to save an object, can I know if a field was changed and if so what was the previous value?
 
ex.  DuesRate.
 
I want to know if the user changed the dues rate during the edit process and I want to know what the previous value was to compare it to the new value.  I want to do this by looking at the object not intercepting the change event of the field and saving the value at the start of the edit.
 
Bill
 



Replies:
Posted By: jeffdoolittle
Date Posted: 16-May-2008 at 10:25am
You can use the DataRowExtensions like this:

            Product p;
            string curValue = p.ProductName;
            string origValue = p.Field<string>(Product.ProductNameEntityColumn.ColumnName, DataRowVersion.Original);

or you can just use standard ADO.NET like this:

            Product p;
            string curValue = p.ProductName;
            string origValue = (string)p[Product.ProductNameEntityColumn.ColumnName, DataRowVersion.Original];

Of course, if you use ADO.NET like this, you'll have to perform your own DBNull checking if the column in question allows null values.




Print Page | Close Window