7.1.1 RadzenDropDown.Value No Longer Works, Manual Assignment Required #1791

Closed
opened 2026-01-29 17:58:37 +00:00 by claunia · 9 comments
Owner

Originally created by @Mike-E-angelo on GitHub (Jun 21, 2025).

Describe the bug
Hello, after upgrading from 7.0.8 to 7.1.1 I have a problem with the RadenDropDown control. It appears the Value property changed from object to T which is a breaking change (the version should be 8.x due to this, but this is another matter altogether 😅).

This is what worked before (notice the error now under Value assignment in 7.1.1):

Image

So now I replace Value with the item reference, and for good measure the SelectedItem as well (using one or the other between the two did not work, either):

Image

However, when doing this the drop down is never selected but rather always shows the Placeholder:

Image

I have to manually assign the selected item via SelectItem in OnAfterRenderAsync for it to display as expected:

protected override Task OnAfterRenderAsync(bool firstRender)
    {
        if (firstRender)
        {
            return _selection.SelectItem(_selected, false);
        }
        return base.OnAfterRenderAsync(firstRender);
    }

Image

To Reproduce

  1. Use the RadzenDropDown in 7.0.8 with the Value assigned, observe selected value
  2. Upgrade to 7.1.1 and observe the Value results in a compilation error (i.e. a breaking change 💥). Additionally, assigning this (or SelectedItem) to the object instance does not work, always resulting in the Placeholder.
  3. Manual assignment in OnAfterRenderAsync is now required.

Expected behavior
Assigning value in 7.1.1 should work as it did in 7.0.8.

Screenshots
Seen above. 😃👍

Desktop (please complete the following information):

  • OS: Windows 10
  • Browser Chrome
  • Version 7.1.1

Additional context
Thank you for all your excellent efforts and work over there. 🙏

Originally created by @Mike-E-angelo on GitHub (Jun 21, 2025). <!-- 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** Hello, after upgrading from `7.0.8` to `7.1.1` I have a problem with the `RadenDropDown` control. It appears the `Value` property changed from `object` to `T` which is a breaking change (the version should be `8.x` due to this, but this is another matter altogether 😅). This is what worked before (notice the error now under `Value` assignment in `7.1.1`): ![Image](https://github.com/user-attachments/assets/5c99f142-f349-4f17-88a7-3e8edeb26146) So now I replace `Value` with the item reference, and for good measure the `SelectedItem` as well (using one or the other between the two did not work, either): ![Image](https://github.com/user-attachments/assets/2f37d8fc-acdc-445c-843d-71080ded1a98) However, when doing this the drop down is never selected but rather always shows the `Placeholder`: ![Image](https://github.com/user-attachments/assets/befe8669-bdd7-4980-bb8b-f106145ced94) I have to manually assign the selected item via `SelectItem` in `OnAfterRenderAsync` for it to display as expected: ``` protected override Task OnAfterRenderAsync(bool firstRender) { if (firstRender) { return _selection.SelectItem(_selected, false); } return base.OnAfterRenderAsync(firstRender); } ``` ![Image](https://github.com/user-attachments/assets/5dbc264b-142b-4ea1-9259-c6e819f86618) **To Reproduce** 1. Use the `RadzenDropDown` in `7.0.8` with the `Value` assigned, observe selected value 2. Upgrade to `7.1.1` and observe the `Value` results in a compilation error (i.e. a breaking change 💥). Additionally, assigning this (or `SelectedItem`) to the object instance does not work, always resulting in the `Placeholder`. 3. Manual assignment in `OnAfterRenderAsync` is now required. **Expected behavior** Assigning value in `7.1.1` should work as it did in `7.0.8`. **Screenshots** Seen above. 😃👍 **Desktop (please complete the following information):** - OS: Windows 10 - Browser Chrome - Version 7.1.1 **Additional context** Thank you for all your excellent efforts and work over there. 🙏✨
Author
Owner

@enchev commented on GitHub (Jun 23, 2025):

It’s caused by this change:
https://github.com/radzenhq/radzen-blazor/pull/2179

Hey @joriverm can it be fixed? We might need to revert it if not.

@enchev commented on GitHub (Jun 23, 2025): It’s caused by this change: https://github.com/radzenhq/radzen-blazor/pull/2179 Hey @joriverm can it be fixed? We might need to revert it if not.
Author
Owner

@joriverm commented on GitHub (Jun 24, 2025):

@enchev : thanks for poking me :)
ill look into it, but im wondering what type ProductTypeView.Identity is. is this a string, int or ProductTypeView @Mike-E-angelo ?
also, what type is _selected ?

once we know that information, an investigation can be started and see what happened before my change, though i have some suspicions ^^

@joriverm commented on GitHub (Jun 24, 2025): @enchev : thanks for poking me :) ill look into it, but im wondering what type `ProductTypeView.Identity` is. is this a `string`, `int` or `ProductTypeView` @Mike-E-angelo ? also, what type is `_selected` ? once we know that information, an investigation can be started and see what happened before my change, though i have some suspicions ^^
Author
Owner

@Mike-E-angelo commented on GitHub (Jun 24, 2025):

Hey there, @joriverm. Thank you for your investigation and questions. ProductTypeView.Identity is an int and _selected is of type ProductTypeView. If you have any more questions, please don't hesitate to let me know, and I will do my best to help you.

@Mike-E-angelo commented on GitHub (Jun 24, 2025): Hey there, @joriverm. Thank you for your investigation and questions. `ProductTypeView.Identity` is an `int` and `_selected` is of type `ProductTypeView`. If you have any more questions, please don't hesitate to let me know, and I will do my best to help you.
Author
Owner

@joriverm commented on GitHub (Jun 24, 2025):

thanks, ill investigate this using some mockup classes and the demo page.
i suspect your TValue should be of type int, since the ValueProperty is directing to an int, not ProductTypeView. this used to compile since Value was of type object, and not TValue, but im wondering what type of value got inserted into Value before my change.

i will investigate this :)

@joriverm commented on GitHub (Jun 24, 2025): thanks, ill investigate this using some mockup classes and the demo page. i suspect your `TValue` should be of type `int`, since the `ValueProperty` is directing to an `int`, not `ProductTypeView`. this used to compile since `Value` was of type `object`, and not TValue, but im wondering what type of value got inserted into `Value` before my change. i will investigate this :)
Author
Owner

@Mike-E-angelo commented on GitHub (Jun 24, 2025):

Thank you again for your investigation, @joriverm. 🙏

Here's the previous markup in full, and worked in 7.0.8:

            <RadzenDropDown @ref="@_selection" TValue="ProductTypeView" ValueProperty="@nameof(ProductTypeView.Identity)" Data="@_candidates" Value="@Input.SelectedTemplate" Placeholder="- Select a content template -"
                            class="featured-selector" SelectedItemChanged="@_change" Disabled="active">
                <Template Context="element">
                    <ContentView TValue="ProductTypeView" Content="@element" Context="view">
                        <ProductTypeViewDisplay Input="@view" />
                    </ContentView>
                </Template>
            </RadzenDropDown>

Here Input is:

    [Parameter]
    public required ProductContentView Input { get; set; }

And ProductContentView is:

public sealed record ProductContentView
{
	public int SelectedTemplate { get; set; }

	[Required, ValidateComplexType]
	public required ProductFiles Files { get; set; }
}

If you need any further information, please let me know and I will assist.

@Mike-E-angelo commented on GitHub (Jun 24, 2025): Thank you again for your investigation, @joriverm. 🙏 Here's the previous markup in full, and worked in `7.0.8`: ``` <RadzenDropDown @ref="@_selection" TValue="ProductTypeView" ValueProperty="@nameof(ProductTypeView.Identity)" Data="@_candidates" Value="@Input.SelectedTemplate" Placeholder="- Select a content template -" class="featured-selector" SelectedItemChanged="@_change" Disabled="active"> <Template Context="element"> <ContentView TValue="ProductTypeView" Content="@element" Context="view"> <ProductTypeViewDisplay Input="@view" /> </ContentView> </Template> </RadzenDropDown> ``` Here `Input` is: ``` [Parameter] public required ProductContentView Input { get; set; } ``` And `ProductContentView` is: ``` public sealed record ProductContentView { public int SelectedTemplate { get; set; } [Required, ValidateComplexType] public required ProductFiles Files { get; set; } } ``` If you need any further information, please let me know and I will assist.
Author
Owner

@joriverm commented on GitHub (Jun 24, 2025):

@Mike-E-angelo & @enchev,

i investigated this using the following, altered, Dropdown example :

@using RadzenBlazorDemos.Models.Northwind

@inherits DbContextPage

<RadzenStack Orientation="Orientation.Horizontal" AlignItems="AlignItems.Center" JustifyContent="JustifyContent.Center" Gap="0.5rem" class="rz-p-sm-12">
    <RadzenLabel Text="Select Value" Component="DropDownTextValueProperties" />
    <RadzenDropDown @ref=_control TValue="Customer" Value="@value" SelectedItemChanged="@OnItemChanged" Data="@customers" TextProperty="@nameof(Customer.CompanyName)" ValueProperty="@nameof(Customer.CustomerID)" Style="width: 100%; max-width: 400px;" Name="DropDownTextValueProperties" />
</RadzenStack>

@{
    var controlValue = _control?.Value;
    var valueType = controlValue?.GetType().Name;
    var selectedItem = _control?.SelectedItem;
    var selectedItemType = selectedItem?.GetType().Name;

    <span>Value : @(controlValue?.ToString() ?? "(null)") / (@(valueType ?? "unknown"))</span>
    <br />
    <span>SelectedItem : @(selectedItem?.ToString() ?? "(null)") / (@(selectedItemType ?? "unknown"))</span>

}

@code {
    string value = "AROUT";
    RadzenDropDown<Customer> _control;
    IEnumerable<Customer> customers;

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

        customers = dbContext.Customers;
    }

    protected override void OnAfterRender(bool firstRender)
    {
        base.OnAfterRender(firstRender);
        if(firstRender)
            OnItemChanged();
    }

    private void OnItemChanged() => StateHasChanged();
}

this compiled in the old version, yes, however value did not get the value of type customer like TValue said it would be. on contrary it is of type string because the value variable is of type string . SelectedItem is as expected the actual model/customer.

Image

if i change value to type int, or start using the ValueChanged eventcallback the control will get upset and crash, as expected. it can't use int/whatever for the CustomerId property that ValueProperty is referencing to, and ValueChanged will crash the control because it can't cast the string/int/whatever to Customer that it requires. aka, its a mess.

if i remove the setting of Value, and select a value, it wont even set Value itself, i assume its because of the type differences (?)

Image

now if i upgrade after my commit, it wont compile like you mentioned @Mike-E-angelo, because it now enforces Value to be of type TValue, and not a random type that just happens to be the same type Value will get. the crashes and mismatches i talked about before are now less possible (there is still a way if you play around with ValueProperty, but i digress)

However, if i change TValue to string it works again just like before.

Image

so in short, i think the change has shown a mistake in your code @Mike-E-angelo , like it did in the unit tests of radzen: https://github.com/radzenhq/radzen-blazor/pull/2179/files#diff-9bf036641805a1ad11f4242e249558140bba43c8a0acdee59d58275b4e119816

this is also why i wanted to introduce a typing of SelectedItem because in this case SelectedItem is the type that Mike had expected and set TValue to, but TValue is just for Value, not for SelectedItem

@enchev : is this enough information and tests to decide what to do with the issue? :)

@joriverm commented on GitHub (Jun 24, 2025): @Mike-E-angelo & @enchev, i investigated this using the following, altered, Dropdown example : ``` @using RadzenBlazorDemos.Models.Northwind @inherits DbContextPage <RadzenStack Orientation="Orientation.Horizontal" AlignItems="AlignItems.Center" JustifyContent="JustifyContent.Center" Gap="0.5rem" class="rz-p-sm-12"> <RadzenLabel Text="Select Value" Component="DropDownTextValueProperties" /> <RadzenDropDown @ref=_control TValue="Customer" Value="@value" SelectedItemChanged="@OnItemChanged" Data="@customers" TextProperty="@nameof(Customer.CompanyName)" ValueProperty="@nameof(Customer.CustomerID)" Style="width: 100%; max-width: 400px;" Name="DropDownTextValueProperties" /> </RadzenStack> @{ var controlValue = _control?.Value; var valueType = controlValue?.GetType().Name; var selectedItem = _control?.SelectedItem; var selectedItemType = selectedItem?.GetType().Name; <span>Value : @(controlValue?.ToString() ?? "(null)") / (@(valueType ?? "unknown"))</span> <br /> <span>SelectedItem : @(selectedItem?.ToString() ?? "(null)") / (@(selectedItemType ?? "unknown"))</span> } @code { string value = "AROUT"; RadzenDropDown<Customer> _control; IEnumerable<Customer> customers; protected override async Task OnInitializedAsync() { await base.OnInitializedAsync(); customers = dbContext.Customers; } protected override void OnAfterRender(bool firstRender) { base.OnAfterRender(firstRender); if(firstRender) OnItemChanged(); } private void OnItemChanged() => StateHasChanged(); } ``` this compiled in the old version, yes, however value did *not* get the value of type customer like TValue said it would be. on contrary it is of type string because the `value` variable is of type string . SelectedItem is as expected the actual model/customer. ![Image](https://github.com/user-attachments/assets/f5f4bfb4-baf2-4a08-9a41-12fd220edfbb) if i change `value` to type `int`, or start using the `ValueChanged` eventcallback the control will get upset and crash, as expected. it can't use `int`/whatever for the `CustomerId` property that `ValueProperty` is referencing to, and `ValueChanged` will crash the control because it can't cast the `string`/`int`/whatever to `Customer` that it requires. aka, its a mess. if i remove the setting of `Value`, and select a value, it wont even set `Value` itself, i assume its because of the type differences (?) ![Image](https://github.com/user-attachments/assets/d22eb120-94c3-4154-bc77-4d73b2365fab) now if i upgrade after my commit, it wont compile like you mentioned @Mike-E-angelo, because it now enforces Value to be of type TValue, and not a random type that just happens to be the same type Value will get. the crashes and mismatches i talked about before are now less possible (there is still a way if you play around with `ValueProperty`, but i digress) However, if i change `TValue` to `string` it works again just like before. ![Image](https://github.com/user-attachments/assets/d682536c-e1dd-4ff3-87a1-903f74ddd7d1) so in short, i think the change has shown a mistake in your code @Mike-E-angelo , like it did in the unit tests of radzen: https://github.com/radzenhq/radzen-blazor/pull/2179/files#diff-9bf036641805a1ad11f4242e249558140bba43c8a0acdee59d58275b4e119816 this is also why i wanted to introduce a typing of `SelectedItem` because in this case `SelectedItem` is the type that Mike had expected and set `TValue` to, but `TValue` is just for `Value`, not for `SelectedItem` @enchev : is this enough information and tests to decide what to do with the issue? :)
Author
Owner

@Mike-E-angelo commented on GitHub (Jun 24, 2025):

Thank you for the additional context @joriverm 🙏 The primary concern to me is that if I supply the Value property, it does not appear to work, and I end up with the Placeholder displayed now:

I have to manually apply the SelectItem to ensure the dropdown displays as expected:

protected override Task OnAfterRenderAsync(bool firstRender)
    {
        if (firstRender)
        {
            return _selection.SelectItem(_selected, false);
        }
        return base.OnAfterRenderAsync(firstRender);
    }

@Mike-E-angelo commented on GitHub (Jun 24, 2025): Thank you for the additional context @joriverm 🙏 The primary concern to me is that if I supply the `Value` property, it does not appear to work, and I end up with the Placeholder displayed now: ![](https://private-user-images.githubusercontent.com/2931376/457559229-befe8669-bdd7-4980-bb8b-f106145ced94.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3NTA3NTQwMjUsIm5iZiI6MTc1MDc1MzcyNSwicGF0aCI6Ii8yOTMxMzc2LzQ1NzU1OTIyOS1iZWZlODY2OS1iZGQ3LTQ5ODAtYmI4Yi1mMTA2MTQ1Y2VkOTQucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI1MDYyNCUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNTA2MjRUMDgyODQ1WiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9ZTcxMjhmM2I0YzkxM2ZkODJiMjk0ZTIxNGY4MzcwNTJkZjYxZDNmNzgwNmU5Zjc4MDFkZWY4NjdiZTNhODNmMyZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QifQ.3AU1Lo_LrQ3LjKpmXDBszeqcKErtLxc-WN8eJ7W2qXE) I have to manually apply the `SelectItem` to ensure the dropdown displays as expected: ``` protected override Task OnAfterRenderAsync(bool firstRender) { if (firstRender) { return _selection.SelectItem(_selected, false); } return base.OnAfterRenderAsync(firstRender); } ```
Author
Owner

@joriverm commented on GitHub (Jun 24, 2025):

@Mike-E-angelo : from what you said you passed _selected to Value, which is of type ProductTypeView, but the ValueProperty is looking for an int. those are not compatible so it probably fails to find and select your model from the list because of that. i think youre mixing up Value and SelectedItem here.

the above example that i made sets the item by CustomerId (via ValueProperty), and i supplied it with the ID to select, which it did when it loaded so works on my end.

@joriverm commented on GitHub (Jun 24, 2025): @Mike-E-angelo : from what you said you passed `_selected` to `Value`, which is of type `ProductTypeView`, but the `ValueProperty` is looking for an `int`. those are not compatible so it probably fails to find and select your model from the list because of that. i think youre mixing up `Value` and `SelectedItem` here. the above example that i made sets the item by `CustomerId` (via `ValueProperty`), and i supplied it with the ID to select, which it did when it loaded so works on my end.
Author
Owner

@Mike-E-angelo commented on GitHub (Jun 24, 2025):

WOW... I am feeling like a total dunce now. 🤦‍♂️

Thank you for your patience @joriverm and @enchev for helping me walk through this. Yes, I now see the TValue should be int and that totally fixes the problem.

I appreciate your time and efforts in getting me situated. As this has been solved -- painfully on my part 😅 -- I will close this issue.

Btw @enchev you should really consider adding the GitHub Sponsor feature for your repository. I would participate in my gratitude if available!

@Mike-E-angelo commented on GitHub (Jun 24, 2025): WOW... I am feeling like a total dunce now. 🤦‍♂️ Thank you for your patience @joriverm and @enchev for helping me walk through this. Yes, I now see the `TValue` should be `int` and that totally fixes the problem. I appreciate your time and efforts in getting me situated. As this has been solved -- _painfully_ on my part 😅 -- I will close this issue. Btw @enchev you should really consider adding the GitHub Sponsor feature for your repository. I would participate in my gratitude if available!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/radzen-blazor#1791