RadzenDataGrid data filtering Int32 type column raizes an exception "System.OverflowException: Value was either too large or too small for an Int32." #452

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).

Describe the bug
Entering the number "12345678901" 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 12345678901
  4. See error
    [2022-07-05T06:42:27.442Z] Error: System.OverflowException: Value was either too large or too small for an Int32.
    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
The input control should be limited by length or/and has a validator.

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). **Describe the bug** Entering the number "**12345678901**" 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 12345678901 4. See error **[2022-07-05T06:42:27.442Z] Error: System.OverflowException: Value was either too large or too small for an Int32.** 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** The input control should be limited by length or/and has a validator. **Screenshots** ![This is an image](https://downloader.disk.yandex.ru/preview/ae94e58025cf8ba96eb40e1ea572911ed7441c3cacd651c27c0348b4230c3a3d/62c41bc2/A8gMAYn_KrwvkdFpWKBp84yuFJVp_rixCZ965r2h1-LH7bJ3t70PCNiStQDiqfqTWmtWhBMhRDuYvg2jnzOXnw%3D%3D?uid=0&filename=error1_1.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/3a1d071b405d488d9344ccf4926c99fe771c0c1727a15fe0f28857ccd3661b3f/62c41b2d/dyTn_EgQwKiaLBdRdXeReXeweIx6N_2-YqqYfOlw2r1jHwfARaaAM4YpH0feYOrLhS_bBOG8GTWhBDLBSkdcrA%3D%3D?uid=0&filename=error1.jpg&disposition=inline&hash=&limit=0&content_type=image%2Fjpeg&owner_uid=0&tknv=v2&size=2048x2048) **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):

Unable to reproduce it on our demos. If you attempt to enter such string the value will be cleared:
https://blazor.radzen.com/datagrid-simple-filter-menu

@enchev commented on GitHub (Jul 7, 2022): Unable to reproduce it on our demos. If you attempt to enter such string the value will be cleared: https://blazor.radzen.com/datagrid-simple-filter-menu
Author
Owner

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

Good day, Vladimir.

Thank you for your response.

I see that your demo has enabled option FilterMode="FilterMode.SimpleWithMenu"

My settings don't have FilterMode:

<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. I see that your demo has enabled option **FilterMode**="FilterMode.SimpleWithMenu" My settings don't have FilterMode: `<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):

text

@harry-flw commented on GitHub (Jul 7, 2022): ![text](https://downloader.disk.yandex.ru/preview/327d91de17523495e1b8a35b9e72c1de337c513570db609330985a1ca4a9b82b/62c6d96f/rN3jSmDPFWuoZ8hD4bTsGCeMjnBGbwEPCIZi1zxaMVgq8-GysSBc_4E9EHjotL9zXsdG8xIgSQ4jQJF_csLweQ%3D%3D?uid=0&filename=e2.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#452