New Posts New Posts RSS Feed: Checking previous values of properties
  FAQ FAQ  Forum Search   Calendar   Register Register  Login Login

Checking previous values of properties

 Post Reply Post Reply
Author
BillG View Drop Down
DevForce MVP
DevForce MVP
Avatar

Joined: 05-Dec-2007
Location: Monroe, MI
Posts: 233
Post Options Post Options   Quote BillG Quote  Post ReplyReply Direct Link To This Post Topic: Checking previous values of properties
    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
 
Back to Top
jeffdoolittle View Drop Down
Senior Member
Senior Member
Avatar

Joined: 14-Jun-2007
Location: United States
Posts: 146
Post Options Post Options   Quote jeffdoolittle Quote  Post ReplyReply Direct Link To This Post 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.

Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down