RadzenDataGrid OData Column Type Guid - exception on set filter - InvalidCastException: Object must implement IConvertible. #1910

Closed
opened 2026-01-29 18:00:08 +00:00 by claunia · 0 comments
Owner

Originally created by @lexamad on GitHub (Nov 23, 2025).

I'm using a RadzenDataGrid with OData, and I have a method:

async Task LoadData(LoadDataArgs args)

I set filter for column type Guid . However, when I try to get the value from args.Filter, I get an InvalidCastException:

System.InvalidCastException: Object must implement IConvertible. at System.Convert.ChangeType(Object value, Type conversionType, IFormatProvider provider) at Radzen.QueryableExtension.GetColumnODataFilter[Payment](RadzenDataGridColumn``1 column, Object filterValue, FilterOperator columnFilterOperator)

The issue seems to be that the code tries to convert the Guid directly, but Guid does not implement IConvertible. A potential fix would be to check if filterValue is of type Guid and convert it to a string, for example:

filterValue is Guid guidValue ? guidValue.ToString() : filterValue

The trouble spot is in this method snippet:
Radzen.QueryableExtension

`
internal static string GetColumnODataFilter(RadzenDataGridColumn column, object filterValue, FilterOperator columnFilterOperator)

var value = IsEnumerable(column.FilterPropertyType) && column.FilterPropertyType != typeof(string)
? null
: (string)Convert.ChangeType(filterValue is DateTimeOffset ?
((DateTimeOffset)filterValue).UtcDateTime : filterValue is DateOnly ?
((DateOnly)filterValue).ToString("yyy-MM-dd", CultureInfo.InvariantCulture) :
filterValue, typeof(string), CultureInfo.InvariantCulture);
`

Originally created by @lexamad on GitHub (Nov 23, 2025). I'm using a RadzenDataGrid with OData, and I have a method: ` async Task LoadData(LoadDataArgs args) ` I set filter for column type Guid . However, when I try to get the value from args.Filter, I get an InvalidCastException: ` System.InvalidCastException: Object must implement IConvertible. at System.Convert.ChangeType(Object value, Type conversionType, IFormatProvider provider) at Radzen.QueryableExtension.GetColumnODataFilter[Payment](RadzenDataGridColumn``1 column, Object filterValue, FilterOperator columnFilterOperator) ` The issue seems to be that the code tries to convert the Guid directly, but Guid does not implement IConvertible. A potential fix would be to check if filterValue is of type Guid and convert it to a string, for example: ` filterValue is Guid guidValue ? guidValue.ToString() : filterValue ` The trouble spot is in this method snippet: Radzen.QueryableExtension ` internal static string GetColumnODataFilter<T>(RadzenDataGridColumn<T> column, object filterValue, FilterOperator columnFilterOperator) var value = IsEnumerable(column.FilterPropertyType) && column.FilterPropertyType != typeof(string) ? null : (string)Convert.ChangeType(filterValue is DateTimeOffset ? ((DateTimeOffset)filterValue).UtcDateTime : filterValue is DateOnly ? ((DateOnly)filterValue).ToString("yyy-MM-dd", CultureInfo.InvariantCulture) : filterValue, typeof(string), CultureInfo.InvariantCulture); `
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/radzen-blazor#1910