diff --git a/src/QuickGrid/src/Microsoft.AspNetCore.Components.QuickGrid/Columns/PropertyColumn.cs b/src/QuickGrid/src/Microsoft.AspNetCore.Components.QuickGrid/Columns/PropertyColumn.cs index fbde7c814..ab5f7af90 100644 --- a/src/QuickGrid/src/Microsoft.AspNetCore.Components.QuickGrid/Columns/PropertyColumn.cs +++ b/src/QuickGrid/src/Microsoft.AspNetCore.Components.QuickGrid/Columns/PropertyColumn.cs @@ -1,7 +1,10 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +using System.ComponentModel.DataAnnotations; +using System.ComponentModel; using System.Linq.Expressions; +using System.Reflection; using Microsoft.AspNetCore.Components.Rendering; namespace Microsoft.AspNetCore.Components.QuickGrid; @@ -65,7 +68,10 @@ protected override void OnParametersSet() if (Title is null && Property.Body is MemberExpression memberExpression) { - Title = memberExpression.Member.Name; + var memberInfo = memberExpression.Member; + var displayName = memberInfo?.GetCustomAttribute(typeof(DisplayNameAttribute)) as DisplayNameAttribute; + var display = memberInfo?.GetCustomAttribute(typeof(DisplayAttribute)) as DisplayAttribute; + Title = displayName?.DisplayName ?? display?.Name ?? memberInfo?.Name ?? ""; } }