Dynamic RadzenRadioButtonList

Hi,

Can you create a dynamic RadzenRadioButtonList (items load from a class)? Can you give me an example?

Can the value of each item be a string or does it necessarily have to be an int?

Thanks in advance.

Hi @at_extchj232

Can you create a dynamic RadzenRadioButtonList (items load from a class)? Can you give me an example?

Yes you can! Just get the data, store it in a property and use foreach to create the items:

<RadzenRadioButtonList @bind-Value="value" TValue="int">
  <Items>
  @if (data != null)
   {
     @foreach (var item in data)
      {
       <RadzenRadioButtonListItem Text="@item.TextProperty" 
            Value="@item.ValueProperty" />
      }
   }
  </Items>
</RadzenRadioButtonList>

Can the value of each item be a string or does it necessarily have to be an int?

It can be anything - just set TValue.

<RadzenRadioButtonList @bind-Value="value" TValue="string">

Thank you very much, I'll try it.