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


3 Replies 1 reply marked as answer

PK Priyanka Karthikeyan Syncfusion Team September 12, 2025 12:49 PM UTC

Hi Julien Barach,

Thank you for reaching out. The issue you're experiencing with List<enum> binding is due to type mismatches between the TValue generic parameter and the actual data source structure.

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
 
It's recommended to use 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>


 

Regards,
Priyanka K


JB Julien Barach September 12, 2025 02:59 PM UTC

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



MR Mallesh Ravi Chandran Syncfusion Team September 24, 2025 01:05 PM UTC

When binding enum values using 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.
However, In MultiSelect internally uses object-based selection and serialization for multiple values. It expects the selected values to be primitive types or types that can be easily serialized and matched. When using KeyValuePair<ETest, string>, the component may not correctly extract and bind the Key values into a List<ETest> due to:
  • 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.

To resolve this, it is recommended to use 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.

Sample  https://blazorplayground.syncfusion.com/VNLIDurAWkyhGlzX

Please review the attached sample demonstrating the working configuration using MultiSelect

Marked as answer
Loader.
Up arrow icon