straightforward way to set Select Items from Enum values? #3324
Answered
by
vnbaaij
adamfoneil
asked this question in
Q&A
-
I'm wanting to fill a select box with enum values. I tried this <FluentSelect @bind-Value="newPaymentMethod.Type" Label="Type" Items="FluentUI.EnumOptions<PaymentMethodType>()" /> where I made my own helper method public static IEnumerable<Option<T>> EnumOptions<T>() where T : struct, Enum
{
var values = Enum.GetValues<T>();
return values.Select(val => new Option<T>() { Value = val, Text = val.ToString() });
} But I'm getting this error
I don't see an enum-related example in the Select documentation. |
Beta Was this translation helpful? Give feedback.
Answered by
vnbaaij
Feb 9, 2025
Replies: 1 comment
-
You can do it like this : <FluentSelect Items=@(Enum.GetValues()) @bind-SelectedOption="@vertical" /> |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
adamfoneil
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You can do it like this :
<FluentSelect Items=@(Enum.GetValues()) @bind-SelectedOption="@vertical" />