2

I have populated a RadzenDropDown in the code shown below,

<RadzenDropDown @bind-Value="SomethingValueSelected" TValue="int" AllowFiltering="false" AllowClear="false" SelectedItem="0" SelectedItemsText="Test-1"
                        Data=@SomethingList TextProperty="Name" ValueProperty="Value"/>

Here is the list with populated items:

List<SomethingDTO> SomethingList= new List<SomethingDTO>(){ new SomethingDTO{ Name = "Test-1", Value = -1 },
                                                                                new SomethingDTO{ Name = "Test0", Value = 0 },
                                                                                new SomethingDTO{ Name = "Test1", Value = 1 },
                                                                                new SomethingDTO{ Name = "Test2", Value  = 2 },
                                                                                new SomethingDTO{ Name = "Test5", Value = 5 }};
int SomethingValueSelected;

And here is what i get when page loads: enter image description hereenter image description here

My question is, how do I get automatically selected item called "Test-1", with the value of -1?

aca
  • 1,071
  • 5
  • 15

1 Answers1

1

Well it seems like quite a simple one - just set the value of element that is being binded to a value that you prefer, in my case it was

int SomethingValueSelected = -1;
aca
  • 1,071
  • 5
  • 15