Running grid.UpdateRow or grid.InsertRow results in error in Maui apps. #507

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

Originally created by @julianadormon on GitHub (Aug 13, 2022).

Describe the bug
I have been running the RadzenDataGrid (version 3.18.14) in an Electron app without issue.
I migrated the code to a Maui Blazor app which targets both Windows and macOS.
I upgraded the Radzen component to 3.20.xx latest.
I made no changes to my Radzen code. The grid loads fine, however, when trying to run either [grid-instance].InsertRow or [grid-instance].EditRow, I can see the grid changes to my edit/add template but I get the following unhandled error, even though my calls are wrapped in a try/catch block:

The ParameterView instance can no longer be read because it has expired. ParameterView can only be read synchronously and must not be stored for later use.
at Microsoft.AspNetCore.Components.Rendering.ParameterViewLifetime.AssertNotExpired()
at Microsoft.AspNetCore.Components.ParameterView.TryGetValue[TValue](String parameterName, TValue& result)
at Radzen.Blazor.RadzenDataGridColumn`1.SetParametersAsync(ParameterView parameters)
at Microsoft.AspNetCore.Components.RenderTree.Renderer.GetErrorHandledTask(Task taskToHandle, ComponentState owningComponentState)
NotifyUnhandledException @ blazor.webview.js:1
(anonymous) @ blazor.webview.js:1
(anonymous) @ VM8:7
(anonymous) @ VM7:1

To Reproduce
Steps to reproduce the behavior:

  1. Run grid.Insert or grid.Update while debugging a macOS (maccatalyst) or Windows Maui Blazor app.

Expected behavior
No error.

Screenshots
image

Desktop (please complete the following information):

  • OS: The same error is encountered running on MacCatalyst or in Windows.
  • Version: I tried running the older version (3.18.xx) which is working in my Electron version but I still get the same error.

Additional context
Running Visual Studio Community 2022 (64-bit) - Current Version 17.3.0 on my WIndows machine.
Running Visual Studio Community 2022 Mac Preview Version 17.4

Originally created by @julianadormon on GitHub (Aug 13, 2022). <!-- IMPORTANT: Read this first!!! 1. If you own a Radzen Professional or Еnterprise subscription you can report your issue or ask us a question via email at info@radzen.com. Radzen staff will reply within 24 hours (Professional) or 16 hours (Enterprise) 2. The Radzen staff guarantees a response to issues in this repo only to paid subscribers. 3. If you have a HOW TO question start a new forum thread in the Radzen Community forum: https://forum.radzen.com. Radzen staff will close issues that are HOWTO questions. 4. Please adhere to the issue template. Specify all the steps required to reproduce the issue or link a project which reproduces it easily (without requiring extra steps such as restoring a database). --> **Describe the bug** I have been running the RadzenDataGrid (version 3.18.14) in an Electron app without issue. I migrated the code to a Maui Blazor app which targets both Windows and macOS. I upgraded the Radzen component to 3.20.xx latest. I made no changes to my Radzen code. The grid loads fine, however, when trying to run either [grid-instance].InsertRow or [grid-instance].EditRow, I can see the grid changes to my edit/add template but I get the following unhandled error, even though my calls are wrapped in a try/catch block: The ParameterView instance can no longer be read because it has expired. ParameterView can only be read synchronously and must not be stored for later use. at Microsoft.AspNetCore.Components.Rendering.ParameterViewLifetime.AssertNotExpired() at Microsoft.AspNetCore.Components.ParameterView.TryGetValue[TValue](String parameterName, TValue& result) at Radzen.Blazor.RadzenDataGridColumn`1.SetParametersAsync(ParameterView parameters) at Microsoft.AspNetCore.Components.RenderTree.Renderer.GetErrorHandledTask(Task taskToHandle, ComponentState owningComponentState) NotifyUnhandledException @ blazor.webview.js:1 (anonymous) @ blazor.webview.js:1 (anonymous) @ VM8:7 (anonymous) @ VM7:1 **To Reproduce** Steps to reproduce the behavior: 1. Run grid.Insert or grid.Update while debugging a macOS (maccatalyst) or Windows Maui Blazor app. **Expected behavior** No error. **Screenshots** ![image](https://user-images.githubusercontent.com/89358714/184515557-f6322a73-aef2-44be-85c0-980ea2c064e6.png) **Desktop (please complete the following information):** - OS: The same error is encountered running on MacCatalyst or in Windows. - Version: I tried running the older version (3.18.xx) which is working in my Electron version but I still get the same error. **Additional context** Running Visual Studio Community 2022 (64-bit) - Current Version 17.3.0 on my WIndows machine. Running Visual Studio Community 2022 Mac Preview Version 17.4
Author
Owner

@julianadormon commented on GitHub (Aug 13, 2022):

This is my grid set up:
<RadzenDataGrid @ref="subjectGrid" Data="@subjectVms" TItem="SubjectVm" AllowPaging="true" PageSize="7" Style="height: calc(100vh - 250px);" AllowFiltering="true" FilterMode="FilterMode.Simple" FilterCaseSensitivity="FilterCaseSensitivity.CaseInsensitive" AllowSorting="true" SelectionMode="DataGridSelectionMode.Multiple" EditMode="DataGridEditMode.Single" ExpandMode="DataGridExpandMode.Single" AllowRowSelectOnRowClick="false" AllowColumnResize="true" RowUpdate="@OnUpdateSubjectRow" RowCreate="@OnCreateSubjectRow" class="rz-selectable" AllowCompositeDataCells="true" @bind-Value=@selectedSubjectVms id="SubjectGrid">

           This is how I call the updateRow:
           `<RadzenButton Icon="edit" title="Edit" Size="ButtonSize.Small" ButtonStyle="ButtonStyle.Secondary" Click="@(args => EditSubjectRow(subjectVm))" @onclick:stopPropagation="true" />`
           
           This is where the code errors:
           `async Task EditSubjectRow(SubjectVm subject)
{
    doingEdit = true;
    try
    {
        await subjectGrid.EditRow(subject); // shows update fields
    }
    catch(Exception ex)
    {
        Console.WriteLine(ex.Message);
    }
}`
@julianadormon commented on GitHub (Aug 13, 2022): This is my grid set up: `<RadzenDataGrid @ref="subjectGrid" Data="@subjectVms" TItem="SubjectVm" AllowPaging="true" PageSize="7" Style="height: calc(100vh - 250px);" AllowFiltering="true" FilterMode="FilterMode.Simple" FilterCaseSensitivity="FilterCaseSensitivity.CaseInsensitive" AllowSorting="true" SelectionMode="DataGridSelectionMode.Multiple" EditMode="DataGridEditMode.Single" ExpandMode="DataGridExpandMode.Single" AllowRowSelectOnRowClick="false" AllowColumnResize="true" RowUpdate="@OnUpdateSubjectRow" RowCreate="@OnCreateSubjectRow" class="rz-selectable" AllowCompositeDataCells="true" @bind-Value=@selectedSubjectVms id="SubjectGrid">` This is how I call the updateRow: `<RadzenButton Icon="edit" title="Edit" Size="ButtonSize.Small" ButtonStyle="ButtonStyle.Secondary" Click="@(args => EditSubjectRow(subjectVm))" @onclick:stopPropagation="true" />` This is where the code errors: `async Task EditSubjectRow(SubjectVm subject) { doingEdit = true; try { await subjectGrid.EditRow(subject); // shows update fields } catch(Exception ex) { Console.WriteLine(ex.Message); } }`
Author
Owner

@julianadormon commented on GitHub (Aug 14, 2022):

Ok I found the cause.
I have selectable rows and I was hiding the checkbox columns if the user is doing an edit.

<RadzenDataGridColumn TItem="SubjectVm" Width="35px" Sortable="false" Filterable="false" Visible="@(!doingEdit)" CssClass="v-align-middle"> <HeaderTemplate> <RadzenCheckBox TriState="false" TValue="bool" Value="@(subjectVms.Any(i => selectedSubjectVms != null && selectedSubjectVms.Contains(i)))" Change="@(args => selectedSubjectVms = args ? subjectVms.ToList() : null)" /> </HeaderTemplate> <Template Context="subjectVm"> <RadzenCheckBox TriState="false" Value="@(selectedSubjectVms != null && selectedSubjectVms.Any(x => x.SubjectId == subjectVm.SubjectId))" TValue="bool" Change=@(args => { subjectGrid.SelectRow(subjectVm); }) Style="text-align: center;" /> </Template> </RadzenDataGridColumn>

  If I remove Visible="@(!doingEdit)" property, I no longer get the error.  Again, I'm not sure why this is working in my Electron app and not in Maui, but I hope this helps someone.
@julianadormon commented on GitHub (Aug 14, 2022): Ok I found the cause. I have selectable rows and I was hiding the checkbox columns if the user is doing an edit. `<RadzenDataGridColumn TItem="SubjectVm" Width="35px" Sortable="false" Filterable="false" Visible="@(!doingEdit)" CssClass="v-align-middle"> <HeaderTemplate> <RadzenCheckBox TriState="false" TValue="bool" Value="@(subjectVms.Any(i => selectedSubjectVms != null && selectedSubjectVms.Contains(i)))" Change="@(args => selectedSubjectVms = args ? subjectVms.ToList() : null)" /> </HeaderTemplate> <Template Context="subjectVm"> <RadzenCheckBox TriState="false" Value="@(selectedSubjectVms != null && selectedSubjectVms.Any(x => x.SubjectId == subjectVm.SubjectId))" TValue="bool" Change=@(args => { subjectGrid.SelectRow(subjectVm); }) Style="text-align: center;" /> </Template> </RadzenDataGridColumn>` If I remove Visible="@(!doingEdit)" property, I no longer get the error. Again, I'm not sure why this is working in my Electron app and not in Maui, but I hope this helps someone.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/radzen-blazor#507