How to set radzendropdown's default value?

Hi i have a radzendropdown component in blazor webassembly and im trying to set its default value to the first item in the list of strings i have.

<RadzenGridColumn TItem="Server" Property="Status" Title="Status">
                    <EditTemplate Context="server">
                        <RadzenDropDown @bind-Value="server.Status" Data="@statusList" Style="width:100%" Name="Status" />
                        <RadzenRequiredValidator Text="Status is required" Component="Status" Popup="true"/>
                    </EditTemplate>
</RadzenGridColumn>

Here is my list of strings:

List<string> statusList = new List<string>() { "Active", "Paused", "Acknowledged", "Failure" };

I just would like to know how i can set the default value of the radzendropdown to "Active".

THank you

The selected value of the dropdown is determined by its Value property - in your case @bind-Value="server.Status".

Thank you for that clarification.

I set the @bind-Value to something like "@statusList.First()" but its not working.
Can you advise me on what it should be changed to to get the first value in my statusList

Try with just Value. When using @bind-Value you can't use method invocations - @bind is for two-way binding.

1 Like