Last post May 29, 2020 06:08 PM by FabianKoe
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:
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.
<select multiple class="form-control" @bind="@PostOp.PainStart">
@foreach (var painSite in Enum.GetValues(typeof(PainSite)))
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?
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.