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"/>

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

Same problem, but still different:

<RadzenDropDown Data=@datalist @bind-Value=@data.ga_id AllowClear="false" Placeholder="Wähle aus ..."style="width: 100%;" TextProperty="Name" ValueProperty="ga_id" Name="Ga_Id" Change="@(args => OnChange(args, "Ga_ID"))" />

here the drop-down list is filled with a list of objects where Name-property gives the entry in the dropdown list but the ga_id-property is used.

Problem seems that the preselect doesnt happen. In practical example - the id of a sample is 57 but the entry 57 is not selected in the dropdown. The dropdown always displays the placeholder

I suspect that the preselect tries to match the given id to the displayed entry which is the Name for the id 57, instead of matching the ValueProperty

If that was true non of our examples would work.