I'm am working on a blazor server-side webapplication which is basically about patients who can fill out several questionaires about their disease. This data is stored in a database via EF Core. My problem is that all questionaires feature a field, where
the user can specifiy several options, a multiselect, with the underlying data type being a [Flags] Enum:
[Flags]
public enum PainSite
{
BehindBothEyes = 1,
... // 12 options in total
}
When using <InputSelect> I was only able to specify ONE option, since it does not allow the attribute "multiple". Binding one enum option did work but I need the input to be a multiselect! (no matter if dropdown or listbox). Thus I tried the following, which
allows me to actually select multiple values but only one is actually bound and hence stored in the database.
Unfortunately, I couldn't solve the problem regarding [Flags] Enum. I ended up creating an associated class with each SelectItem being a property of type bool and then I used a checkbox in my form. Works fine so far.
None
0 Points
2 Posts
[Flags] Enum - MultiSelect Blazor component
Apr 08, 2020 06:21 AM|FabianKoe|LINK
I'm am working on a blazor server-side webapplication which is basically about patients who can fill out several questionaires about their disease. This data is stored in a database via EF Core. My problem is that all questionaires feature a field, where the user can specifiy several options, a multiselect, with the underlying data type being a [Flags] Enum:
When using <InputSelect> I was only able to specify ONE option, since it does not allow the attribute "multiple". Binding one enum option did work but I need the input to be a multiselect! (no matter if dropdown or listbox). Thus I tried the following, which allows me to actually select multiple values but only one is actually bound and hence stored in the database.
Any idea?
None
0 Points
3 Posts
Re: [Flags] Enum - MultiSelect Blazor component
May 23, 2020 04:12 PM|BlazorFan|LINK
This is two months old, so I assume you found the answer.
Did you end up using a checkbox?
None
0 Points
2 Posts
Re: [Flags] Enum - MultiSelect Blazor component
May 29, 2020 06:08 PM|FabianKoe|LINK
Unfortunately, I couldn't solve the problem regarding [Flags] Enum. I ended up creating an associated class with each SelectItem being a property of type bool and then I used a checkbox in my form. Works fine so far.