UpdateRow of DataGrid inline edit causes KeyNotFoundException #799

Open
opened 2026-01-29 17:44:34 +00:00 by claunia · 0 comments
Owner

Originally created by @Wolfware2023 on GitHub (Apr 6, 2023).

I am replicating the example DataGrid inline edit
Displaying and switching to edit mode works fine. But when I change a text value and save it, I get an error during the call of
await objectGrid.UpdateRow(currentObject);

The error message is

Error: System.Collections.Generic.KeyNotFoundException: The given key 'MyObject { RowGuid = bb19826e-70fd-5a5c-9eeb-0567cd3ac95d, TextProperty = NewText,  CreatedAt = 06.04.2023 13:13:40, CreatedById = ab460de4-5431-479f-b064-d303a58a2023, EditedAt = , EditedById =  }' was not present in the dictionary.
   at System.Collections.Generic.Dictionary`2.get_Item(TKey key)
   at Radzen.Blazor.RadzenDataGrid`1.UpdateRow(TItem item)
   at Pages.ExamplePage.SaveRow(MyObject currentObject) in 

To Reproduce
Steps to reproduce the behavior:

  1. Copy the code from the example
  2. Remove all code with db context
  3. Replace order with your own object. Mine only had 4 string properties.
  4. See error

Expected behavior
It should work without error like in the example, calling the method defined for RowUpdate next.

  • OS: Windows
  • Browser Edge (111.0.1661.54)
  • Version 4.8.4

Additional context

  • I tried adding the Id property of type Guid, but still got the error.
  • I added KeyProperty to RadzenDateGrid to let it know about my id property, but the error prevails.
  • I also added the Attribute [Key] to the key, same error.
  • I tried a little older version of radzen, also did not change anything.
Originally created by @Wolfware2023 on GitHub (Apr 6, 2023). I am replicating the example [DataGrid inline edit](https://blazor.radzen.com/datagrid-inline-edit) Displaying and switching to edit mode works fine. But when I change a text value and save it, I get an error during the call of `await objectGrid.UpdateRow(currentObject);` The error message is ``` Error: System.Collections.Generic.KeyNotFoundException: The given key 'MyObject { RowGuid = bb19826e-70fd-5a5c-9eeb-0567cd3ac95d, TextProperty = NewText, CreatedAt = 06.04.2023 13:13:40, CreatedById = ab460de4-5431-479f-b064-d303a58a2023, EditedAt = , EditedById = }' was not present in the dictionary. at System.Collections.Generic.Dictionary`2.get_Item(TKey key) at Radzen.Blazor.RadzenDataGrid`1.UpdateRow(TItem item) at Pages.ExamplePage.SaveRow(MyObject currentObject) in ``` **To Reproduce** Steps to reproduce the behavior: 1. Copy the code from the example 2. Remove all code with db context 3. Replace order with your own object. Mine only had 4 string properties. 4. See error **Expected behavior** It should work without error like in the example, calling the method defined for RowUpdate next. - OS: Windows - Browser Edge (111.0.1661.54) - Version 4.8.4 **Additional context** - I tried adding the Id property of type Guid, but still got the error. - I added KeyProperty to RadzenDateGrid to let it know about my id property, but the error prevails. - I also added the Attribute [Key] to the key, same error. - I tried a little older version of radzen, also did not change anything.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/radzen-blazor#799