RadzenDataGrid data filtering Int32 type column raizes an exception "System.FormatException: Input string was not in a correct format" #453

Closed
opened 2026-01-29 17:37:33 +00:00 by claunia · 6 comments
Owner

Originally created by @harry-flw on GitHub (Jul 5, 2022).

RadzenDataGrid data filtering Int32 type column raizes an exception "System.FormatException: Input string was not in a correct format"

Describe the bug
Entering the number "-1" in the field in the filter dialog results in a fatal error.

To Reproduce
Steps to reproduce the behavior:

  1. Open the page where is the RadzenDataGrid component. The RadzenDataGrid component must have an Int32 column and the option AllowFiltering must be set to "true"
  2. Click on the filter icon for the Int32 column.
  3. In the filtering dialog that appears, enter the value -1. It's important do not press arrows, just type -1
  4. See error
    [2022-07-05T07:18:34.439Z] Error: System.FormatException: Input string was not in a correct format.
    at System.Number.ThrowOverflowOrFormatException(ParsingStatus status, TypeCode type)
    at System.Number.ParseInt32(ReadOnlySpan1 value, NumberStyles styles, NumberFormatInfo info) at System.String.System.IConvertible.ToInt32(IFormatProvider provider) at System.Convert.ChangeType(Object value, Type conversionType, IFormatProvider provider) at Radzen.Blazor.RadzenDataGrid1.<>c__DisplayClass48_1.b__3(ChangeEventArgs args)
    --- End of stack trace from previous location ---
    at Microsoft.AspNetCore.Components.ComponentBase.CallStateHasChangedOnAsyncCompletion(Task task)
    at Microsoft.AspNetCore.Components.RenderTree.Renderer.GetErrorHandledTask(Task taskToHandle)

Expected behavior
If user can enter -1 without any errors by arrows in the field - user must have a possibility to enter -1 from keyboard without any errors.

Screenshots
This is an image

This is an image

Desktop (please complete the following information):

  • OS: Windows 10
  • Browser: Microsoft Edge version 103.0.1264.44 (Official build) (64-bit)
  • Version of Radzen.Blazor 3.19.2
Originally created by @harry-flw on GitHub (Jul 5, 2022). RadzenDataGrid data filtering Int32 type column raizes an exception "System.FormatException: Input string was not in a correct format" **Describe the bug** Entering the number "**-1**" in the field in the filter dialog results in a fatal error. **To Reproduce** Steps to reproduce the behavior: 1. Open the page where is the **RadzenDataGrid** component. The **RadzenDataGrid** component must have an **Int32** column and the option **AllowFiltering** must be set to "true" 2. Click on the filter icon for the Int32 column. 3. In the filtering dialog that appears, enter the value -1. It's important do not press arrows, just type -1 4. See error **[2022-07-05T07:18:34.439Z] Error: System.FormatException: Input string was not in a correct format.** at System.Number.ThrowOverflowOrFormatException(ParsingStatus status, TypeCode type) at System.Number.ParseInt32(ReadOnlySpan`1 value, NumberStyles styles, NumberFormatInfo info) at System.String.System.IConvertible.ToInt32(IFormatProvider provider) at System.Convert.ChangeType(Object value, Type conversionType, IFormatProvider provider) at Radzen.Blazor.RadzenDataGrid`1.<>c__DisplayClass48_1.<DrawNumericFilter>b__3(ChangeEventArgs args) --- End of stack trace from previous location --- at Microsoft.AspNetCore.Components.ComponentBase.CallStateHasChangedOnAsyncCompletion(Task task) at Microsoft.AspNetCore.Components.RenderTree.Renderer.GetErrorHandledTask(Task taskToHandle) **Expected behavior** If user can enter -1 without any errors by arrows in the field - user must have a possibility to enter -1 from keyboard without any errors. **Screenshots** ![This is an image](https://downloader.disk.yandex.ru/preview/6ca17f35c56c1756ee326f21298b32856a6b9eaf6a9b4b92fa78e4bf30f40793/62c41f6a/pprWAn8Kqw50QEFnrFv1Do6SVemTO47aPjQMBP7eHFjSbqq1rfq-WYSFYzqQkCitDA1pYrgPty09rVgo3-J8nA%3D%3D?uid=0&filename=error2.jpg&disposition=inline&hash=&limit=0&content_type=image%2Fjpeg&owner_uid=0&tknv=v2&size=1920x1057) ![This is an image](https://downloader.disk.yandex.ru/preview/c8501e6a406abcbebc1d8f7dbba440ece1bbf97049e3448ffd7797765e693197/62c41fba/utoLmLIFOpc31-cO9zG_u03i2gQy8jsBNGyX2SBrg8GS0JiiWWRuQdzQQPzRi81UIKZeYIa9CZR7r1b0U_Wd0g%3D%3D?uid=0&filename=error2_1.jpg&disposition=inline&hash=&limit=0&content_type=image%2Fjpeg&owner_uid=0&tknv=v2&size=1920x1057) **Desktop (please complete the following information):** - OS: Windows 10 - Browser: Microsoft Edge version 103.0.1264.44 (Official build) (64-bit) - Version of Radzen.Blazor 3.19.2
Author
Owner

@enchev commented on GitHub (Jul 7, 2022):

I'm unable to reproduce such exception on our demos:
image

@enchev commented on GitHub (Jul 7, 2022): I'm unable to reproduce such exception on our demos: ![image](https://user-images.githubusercontent.com/5804953/177700036-499abab6-e6a2-44d0-9f61-239075dd98a8.png)
Author
Owner

@harry-flw commented on GitHub (Jul 7, 2022):

Good day, Vladimir.

Thank you for your response.

My settings are:

<RadzenDataGrid AllowFiltering="true" AllowPaging="true" PageSize="14" AllowSorting="true" EditMode="DataGridEditMode.Single">

And I can reproduce this bug anytime.

@harry-flw commented on GitHub (Jul 7, 2022): Good day, Vladimir. Thank you for your response. My settings are: `<RadzenDataGrid AllowFiltering="true" AllowPaging="true" PageSize="14" AllowSorting="true" EditMode="DataGridEditMode.Single">` And I can reproduce this bug anytime.
Author
Owner

@harry-flw commented on GitHub (Jul 7, 2022):

Open your demo here: https://blazor.radzen.com/datagrid-enum-filter and do the same things for the ID column. Open developer console and you will see the same bug.

@harry-flw commented on GitHub (Jul 7, 2022): Open your demo here: https://blazor.radzen.com/datagrid-enum-filter and do the same things for the ID column. Open developer console and you will see the same bug.
Author
Owner

@harry-flw commented on GitHub (Jul 7, 2022):

As the exception said the problem is in the DrawNumericFilter method. As I understand it's about this line:

column.SetFilterValue(!string.IsNullOrWhiteSpace(str) ? Convert.ChangeType((object) str, Nullable.GetUnderlyingType(type)) : (object) null, isFirst);

@harry-flw commented on GitHub (Jul 7, 2022): As the exception said the problem is in the **DrawNumericFilter** method. As I understand it's about this line: `column.SetFilterValue(!string.IsNullOrWhiteSpace(str) ? Convert.ChangeType((object) str, Nullable.GetUnderlyingType(type)) : (object) null, isFirst);`
Author
Owner

@harry-flw commented on GitHub (Jul 7, 2022):

alt text

@harry-flw commented on GitHub (Jul 7, 2022): ![alt text](https://downloader.disk.yandex.ru/preview/2292964beb4f761108a52183a8f40e538bb781961430b5411398472def7f9d6e/62c6d9cc/JS5gIoSeAG4i-LeG-z77-WjbBLdE9Rjoon5u8wIVim3Na0EG6Mb19tMQCA1BMC54ZOSzzO-CIp-glTbV26gP4w%3D%3D?uid=0&filename=e1.jpg&disposition=inline&hash=&limit=0&content_type=image%2Fjpeg&owner_uid=0&tknv=v2&size=2048x2048)
Author
Owner

@harry-flw commented on GitHub (Jul 7, 2022):

Dear Vladimir,

please inform me if I need to reopen this bug.

Thank you.

@harry-flw commented on GitHub (Jul 7, 2022): Dear Vladimir, please inform me if I need to reopen this bug. Thank you.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/radzen-blazor#453