Tuesday, May 25, 2010

Row not found or changed - LinqDataSource

Row not found or changed - LinqDataSource: "The 'row not found or changed' exception happens when either the primary key isn't set, or when the old values for any columns marked for UpdateCheck do not match what is in the database. The best way to track down which column is causing the exception is by inspecting the OriginalObject in the Updating event args.



The Update parameter's ConvertEmptyStringToNull will affect both the old and new values. You should see the difference when inspecting the OriginalObject and NewObject in the Updating event args.



If the column is marked for UpdateCheck and LinqDataSource has StoreOriginalValuesInViewState enabled (the default), then the original value is the value stored by LinqDataSource during the previous Select. Otherwise, the original value will come from the databound control, if available, using 2-way databinding. The values stored by LinqDataSource will likely match the values from the database, whereas those coming from the databound control may have been converted to empty strings.



Compare the OriginalObject values from the Updating event with those in the database to confirm which column is causing the exception. If you need more help, feel free to send me a repro or discuss further over email: chenriks at microsoft dot com

- Sent using Google Toolbar"

No comments:

Post a Comment