Ticket Q314701
Visible to All Users

ASPxGridView - How to compare old and new values

created 14 years ago

When performing a RowUpdate I update information to reflect the last change and the person who did so. However, I only want to do so if a change has actually been made.
I do not see a way to do this other than to compare the old and new e value for each field.
More of a problem, is when I do so on a field with a SpinEdit that allows Nulls, without doing any editing the new value compares as "Nothing" and the old value as "System.DBNull."
I would have thought that the old and new values would be the same without any editing. Is that not the case, and is there an easier way to know if a row has changed than comparing each field?

Answers

created 14 years ago

Hello Larry,
Thank you for your question. In fact, you can compare old and new values in the ASPxGridView.RowUpdating event handler if you loop through the e.OldValues dictionary, then extract the Key value of each item and then search for an appropriate value in the e.NewValues dictionary.
> More of a problem, is when I do so on a field with a SpinEdit that allows Nulls, without doing any editing the new value compares as "Nothing" and the old value as "System.DBNull."
The ASPxSpinEdit control works with the Decimal type (the type of the ASPxSpinEdit.Number property) that does not work with the System.DBNull value. If you need to convert from the Nothing/Null value to the DBNull value, you should use the following code:

Visual Basic
If (e.NewValue(...) = Nothing) Then e.NewValue(...) = System.DBNull End If

Thanks,
Vest

    Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

    Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.