Breaking Change T929217
Visible to All Users

Core - ListView may throw exceptions when a public key property is missing in a business class

What Changed

In v.20.2, ASP.NET Blazor and Web Forms apps will throw exceptions if a business object type displayed in a ListView does not have a public Key Property.

Reasons for Change

A business class without a public key property may cause issues with selection, filtering, etc. in a web ListView due to a different control architecture in client-server apps (it may work fine in WinForms). For more information, see Web - How to avoid issues with data-bound controls due to missing or non-unique key values.

Previously, these issues could appear in unexpected places without developers knowing about them. We decided to throw exceptions once such situations are detected to save developers and end-users from more serious issues in production.

Impact on Existing Apps

This change will affect your ASP.NET Web Forms and Blazor apps if you are using an object without a key in your ListView. This may often happen with non-persistent classes.
If your class is non-persistent, inherit it from DevExpress.ExpressApp.NonPersistentBaseObject or declare a public key property with DevExpress.ExpressApp.Data.KeyAttribute. For more solutions, see Web - How to avoid issues with data-bound controls due to missing or non-unique key values.

How to Revert to Previous Behavior

In the YourSolutionName.Xxx/XxxApplication.xx file, override the following method in your WebApplication or BlazorApplication descendant:

C#
protected override bool ThrowIfNoKeyOnListViewCreation(DC.ITypeInfo typeInfo) { return false; }
Visual Basic
Protected Overrides Function ThrowIfNoKeyOnListViewCreation(ByVal typeInfo As DC.ITypeInfo) As Boolean Return False End Function

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.