Radzen Datagrid not using object's overridden GetHashCode() method #1277

Closed
opened 2026-01-29 17:51:27 +00:00 by claunia · 2 comments
Owner

Originally created by @xtreampb on GitHub (Jun 23, 2024).

Describe the bug
A radzen DataGrid who's template type is one that overrides Equals and GetHashCode will throw a KeyNotFound exception when trying to add a new object to the datagrid

To Reproduce
Steps to reproduce the behavior:

  1. Create Class that an int public property.
  2. override the equals and gethashcode methods
  3. create datagrid following example on demo site
  4. in the edit template, the radzen numeric should bind-value to the int property
  5. attempt to insert new value. ensure you change the value of the int property to anything other than default (0)
  6. try to save the new object
  7. See error

example source posted in the community at: https://forum.radzen.com/t/radzen-datagrid-and-overridden-equals-hashcode/17663

Expected behavior
I should be able to override the GetHashCode method and be able to use same object in a radzen data grid

Screenshots
If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

  • OS: Windows
  • Browser: Edge
  • Version: 4.32.8

Additional context
removing the GetHashCode and the Equals method overrides from my class solves the issue, but this isn't a satisfactory work around as i need to use override the Equals method, which also calls for override the GetHashCode method.

Originally created by @xtreampb on GitHub (Jun 23, 2024). **Describe the bug** A radzen DataGrid who's template type is one that overrides Equals and GetHashCode will throw a `KeyNotFound` exception when trying to add a new object to the datagrid **To Reproduce** Steps to reproduce the behavior: 1. Create Class that an int public property. 2. override the equals and gethashcode methods 3. create datagrid following example on demo site 4. in the edit template, the radzen numeric should bind-value to the int property 5. attempt to insert new value. ensure you change the value of the int property to anything other than default (0) 6. try to save the new object 7. See error example source posted in the community at: https://forum.radzen.com/t/radzen-datagrid-and-overridden-equals-hashcode/17663 **Expected behavior** I should be able to override the GetHashCode method and be able to use same object in a radzen data grid **Screenshots** If applicable, add screenshots to help explain your problem. **Desktop (please complete the following information):** - OS: Windows - Browser: Edge - Version: 4.32.8 **Additional context** removing the GetHashCode and the Equals method overrides from my class solves the issue, but this isn't a satisfactory work around as i need to use override the Equals method, which also calls for override the GetHashCode method.
Author
Owner

@enchev commented on GitHub (Jun 24, 2024):

Let's continue the conversation in the forum thread.

@enchev commented on GitHub (Jun 24, 2024): Let's continue the conversation in the forum thread.
Author
Owner

@xtreampb commented on GitHub (Jun 24, 2024):

looks like this is addressed in commit 3fbd64338c

@xtreampb commented on GitHub (Jun 24, 2024): looks like this is addressed in commit 3fbd64338cc7766fdbe99be4a544a396b5feb184
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/radzen-blazor#1277