DropDownDataGrid exception when changing data object #1595

Open
opened 2026-01-29 17:55:51 +00:00 by claunia · 3 comments
Owner

Originally created by @JohannesBauer97 on GitHub (Feb 3, 2025).

Describe the bug
DropDownDataGrid raises an exception when updating the bound Data list WHILE the user is not on the first page of the paginated datagrid.

To Reproduce

  1. Open https://blazor.radzen.com/dropdown-datagrid?theme=material3
  2. Paste following code into any demo editor:
@using RadzenBlazorDemos.Models.Northwind

@inherits DbContextPage

<RadzenStack Orientation="Orientation.Horizontal" AlignItems="AlignItems.Center" JustifyContent="JustifyContent.Center" Gap="0.5rem" class="rz-p-12">
    <RadzenLabel Text="Select Value" Component="DropDownDataGridTemplate" />
    <RadzenDropDownDataGrid TValue="Customer" Value=@value Data=@customers TextProperty="@nameof(Customer.CompanyName)" Name="DropDownDataGridTemplate">
        <Columns>
            <RadzenDropDownDataGridColumn Property="@nameof(Customer.CompanyName)" Title="Name" Width="200px" SortOrder="SortOrder.Ascending"/>
        </Columns>
        <FooterTemplate>
            <RadzenStack AlignItems="AlignItems.Center">
                <RadzenButton Icon="delete" Click="@(l => customers = new List<Customer>())" Style="margin: 10px 0 10px 0;"/>
            </RadzenStack>
        </FooterTemplate>
    </RadzenDropDownDataGrid>
</RadzenStack>

@code {
    Customer? value = null;
    List<Customer> customers;

    protected override async Task OnInitializedAsync()
    {
        await base.OnInitializedAsync();

        customers = dbContext.Customers.ToList();
    }
}
  1. Run
  2. Navigate to the second page or later and click the delete button

Expected behavior
DropDownDataGrid displays an empty list after clicking the delete button.
This works when the button is clicked on the first page, but an exception is thrown when the user is on any other page.

Error Details

crit: Microsoft.AspNetCore.Components.WebAssembly.Rendering.WebAssemblyRenderer[100]
      Unhandled exception rendering component: 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.
System.InvalidOperationException: 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.GetEnumerator()
   at Microsoft.AspNetCore.Components.ParameterView.TryGetValue[Boolean](String parameterName, Boolean& result)
   at Radzen.ParameterViewExtensions.DidParameterChange[Boolean](ParameterView parameters, String parameterName, Boolean parameterValue)
   at Radzen.DataBoundFormComponent`1.<SetParametersAsync>d__82[[RadzenBlazorDemos.Models.Northwind.Customer, RadzenBlazorDemos, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].MoveNext()
   at Radzen.DropDownBase`1.<SetParametersAsync>d__126[[RadzenBlazorDemos.Models.Northwind.Customer, RadzenBlazorDemos, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].MoveNext()
   at Radzen.Blazor.RadzenDropDownDataGrid`1.<SetParametersAsync>d__167[[RadzenBlazorDemos.Models.Northwind.Customer, RadzenBlazorDemos, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].MoveNext()
   at Microsoft.AspNetCore.Components.RenderTree.Renderer.GetErrorHandledTask(Task taskToHandle, ComponentState owningComponentState)

Desktop (please complete the following information):

  • OS: MacOS/Windows
  • Browser Safari
  • Version Latest - 5.9.7

Additional context
Add any other context about the problem here.

Originally created by @JohannesBauer97 on GitHub (Feb 3, 2025). **Describe the bug** DropDownDataGrid raises an exception when updating the bound Data list WHILE the user is not on the first page of the paginated datagrid. **To Reproduce** 1. Open https://blazor.radzen.com/dropdown-datagrid?theme=material3 2. Paste following code into any demo editor: ````csharp @using RadzenBlazorDemos.Models.Northwind @inherits DbContextPage <RadzenStack Orientation="Orientation.Horizontal" AlignItems="AlignItems.Center" JustifyContent="JustifyContent.Center" Gap="0.5rem" class="rz-p-12"> <RadzenLabel Text="Select Value" Component="DropDownDataGridTemplate" /> <RadzenDropDownDataGrid TValue="Customer" Value=@value Data=@customers TextProperty="@nameof(Customer.CompanyName)" Name="DropDownDataGridTemplate"> <Columns> <RadzenDropDownDataGridColumn Property="@nameof(Customer.CompanyName)" Title="Name" Width="200px" SortOrder="SortOrder.Ascending"/> </Columns> <FooterTemplate> <RadzenStack AlignItems="AlignItems.Center"> <RadzenButton Icon="delete" Click="@(l => customers = new List<Customer>())" Style="margin: 10px 0 10px 0;"/> </RadzenStack> </FooterTemplate> </RadzenDropDownDataGrid> </RadzenStack> @code { Customer? value = null; List<Customer> customers; protected override async Task OnInitializedAsync() { await base.OnInitializedAsync(); customers = dbContext.Customers.ToList(); } } ```` 3. Run 4. Navigate to the **second page** or later and click the delete button **Expected behavior** DropDownDataGrid displays an empty list after clicking the delete button. This works when the button is clicked on the first page, but an exception is thrown when the user is on any other page. **Error Details** ````` crit: Microsoft.AspNetCore.Components.WebAssembly.Rendering.WebAssemblyRenderer[100] Unhandled exception rendering component: 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. System.InvalidOperationException: 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.GetEnumerator() at Microsoft.AspNetCore.Components.ParameterView.TryGetValue[Boolean](String parameterName, Boolean& result) at Radzen.ParameterViewExtensions.DidParameterChange[Boolean](ParameterView parameters, String parameterName, Boolean parameterValue) at Radzen.DataBoundFormComponent`1.<SetParametersAsync>d__82[[RadzenBlazorDemos.Models.Northwind.Customer, RadzenBlazorDemos, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].MoveNext() at Radzen.DropDownBase`1.<SetParametersAsync>d__126[[RadzenBlazorDemos.Models.Northwind.Customer, RadzenBlazorDemos, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].MoveNext() at Radzen.Blazor.RadzenDropDownDataGrid`1.<SetParametersAsync>d__167[[RadzenBlazorDemos.Models.Northwind.Customer, RadzenBlazorDemos, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].MoveNext() at Microsoft.AspNetCore.Components.RenderTree.Renderer.GetErrorHandledTask(Task taskToHandle, ComponentState owningComponentState) ````` **Desktop (please complete the following information):** - OS: MacOS/Windows - Browser Safari - Version Latest - 5.9.7 **Additional context** Add any other context about the problem here.
Author
Owner

@Tom536 commented on GitHub (Feb 4, 2025):

Thanks for that report - I can confirm that I'm facing the exact same issue.

@Tom536 commented on GitHub (Feb 4, 2025): Thanks for that report - I can confirm that I'm facing the exact same issue.
Author
Owner

@enchev commented on GitHub (Feb 5, 2025):

We don't have fix for that at the moment we accept ideas and pull requests. In the meantime you can use the following workaround:

@using RadzenBlazorDemos.Models.Northwind

@inherits DbContextPage

<RadzenStack Orientation="Orientation.Horizontal" AlignItems="AlignItems.Center" JustifyContent="JustifyContent.Center" Gap="0.5rem" class="rz-p-12">
    <RadzenLabel Text="Select Value" Component="DropDownDataGridTemplate" />
    <RadzenDropDownDataGrid @ref=dropDownDataGrid TValue="Customer" Value=@value Data=@customers TextProperty="@nameof(Customer.CompanyName)" Name="DropDownDataGridTemplate">
        <Columns>
            <RadzenDropDownDataGridColumn Property="@nameof(Customer.CompanyName)" Title="Name" Width="200px" SortOrder="SortOrder.Ascending" />
        </Columns>
        <FooterTemplate>
            <RadzenStack AlignItems="AlignItems.Center">
                <RadzenButton Icon="delete" Click="@(l => { customers = new List<Customer>(); dropDownDataGrid.Reload(); })" Style="margin: 10px 0 10px 0;" />
            </RadzenStack>
        </FooterTemplate>
    </RadzenDropDownDataGrid>
</RadzenStack>

@code {
    Customer? value = null;
    List<Customer> customers;
    RadzenDropDownDataGrid<Customer?> dropDownDataGrid;
    protected override async Task OnInitializedAsync()
    {
        await base.OnInitializedAsync();

        customers = dbContext.Customers.ToList();
    }
}
@enchev commented on GitHub (Feb 5, 2025): We don't have fix for that at the moment we accept ideas and pull requests. In the meantime you can use the following workaround: ``` @using RadzenBlazorDemos.Models.Northwind @inherits DbContextPage <RadzenStack Orientation="Orientation.Horizontal" AlignItems="AlignItems.Center" JustifyContent="JustifyContent.Center" Gap="0.5rem" class="rz-p-12"> <RadzenLabel Text="Select Value" Component="DropDownDataGridTemplate" /> <RadzenDropDownDataGrid @ref=dropDownDataGrid TValue="Customer" Value=@value Data=@customers TextProperty="@nameof(Customer.CompanyName)" Name="DropDownDataGridTemplate"> <Columns> <RadzenDropDownDataGridColumn Property="@nameof(Customer.CompanyName)" Title="Name" Width="200px" SortOrder="SortOrder.Ascending" /> </Columns> <FooterTemplate> <RadzenStack AlignItems="AlignItems.Center"> <RadzenButton Icon="delete" Click="@(l => { customers = new List<Customer>(); dropDownDataGrid.Reload(); })" Style="margin: 10px 0 10px 0;" /> </RadzenStack> </FooterTemplate> </RadzenDropDownDataGrid> </RadzenStack> @code { Customer? value = null; List<Customer> customers; RadzenDropDownDataGrid<Customer?> dropDownDataGrid; protected override async Task OnInitializedAsync() { await base.OnInitializedAsync(); customers = dbContext.Customers.ToList(); } } ```
Author
Owner

@Tom536 commented on GitHub (Feb 5, 2025):

Hello Vladimir,

thank you so much for providing the workaround.

It did the trick for me.

-Tom

@Tom536 commented on GitHub (Feb 5, 2025): Hello Vladimir, thank you so much for providing the workaround. It did the trick for me. -Tom
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/radzen-blazor#1595