Impossible to bind a List of enum, the binded parameter will be set to null
Hi,
I'm trying to bind a List of enum in the @bind-Value attribute but whenever I select a value, the binded parameter is set to null.
Please see the repro : https://blazorplayground.syncfusion.com/htVIZatfVoMranfg
Regards,
Julien
TValue="List<ETest>" expects the bound value to be a List<ETest>
But KeyValuePair<ETest, string> creates a struct that doesn't align with enum binding
string[] or List<string> instead of List<enum> for binding with the MultiSelect component:<SfMultiSelect TItem="TestItem" TValue="List<string>" DataSource="list" @bind-Value="form.Binded"> <MultiSelectFieldSettings Text="Value" Value="Key" /> </SfMultiSelect> |
Hi,
That's confusing !
This should work the same way it works on SfDropDownList.
I'm not interested in binding a list of string. I need to bind a list of T where T is an enum.
Otherwise I'll need to convert the list manually later for my purpose and @bind-Value loses its interest.
At least the component should throw a message if for some technical reason on your side the "struct doesn't align with enum binding".
Because here it looks like everything is fine but the bind-Value mecanism gives up silently.
Please see it working with the exact same binding and settings on an SfDropDownList : https://blazorplayground.syncfusion.com/VtLyjOiheBlGIpiO
It's confusing that moving from SfDopDownList to SfMultiSelect does not work in this case.
Is it possible for you to consider making the SfMultiSelect working with binding a list of enum ?
Regards,
Julien
KeyValuePair<Enum, string> as the data source, DropDownList works as expected because it binds a single value and performs direct type matching between the selected item's Value field and the bound property. In this case, the TValue is set to the enum type (e.g., ETest), and the Value field is "Key", which aligns perfectly with the bound property type.- Strict type matching: It may not infer that Key (of type ETest) should be collected into a List<ETest>.
- Serialization mismatch: The internal logic may treat the selected items as object or Enum, not ETest, causing the binding to fail or result in null.
TValue="List<Enum>" in MultiSelect. This allows the component to treat selected values as general enum objects, bypassing strict type checks and ensuring proper binding.Please review the attached sample demonstrating the working configuration using
MultiSelect. - 3 Replies
- 3 Participants
- Marked answer
-
JB Julien Barach
- Sep 4, 2025 07:04 AM UTC
- Sep 24, 2025 01:05 PM UTC