Dropdown Multiple DB field type

Just wanted to say thank you again as it's working in my solution now.

I have one small issue that I have not been able to figure out and I would like to ask for assistance on. In the sample project you provided if you clear all your selections in the dropdown it throws an exception:

dotnet: warn: Microsoft.AspNetCore.Components.Server.Circuits.RemoteRenderer[100]
      Unhandled exception rendering component: Input string was not in a correct format.
      System.FormatException: Input string was not in a correct format.
         at System.Number.ThrowOverflowOrFormatException(ParsingStatus status, TypeCode type)
         at System.Number.ParseInt32(ReadOnlySpan`1 value, NumberStyles styles, NumberFormatInfo info)
         at System.Int32.Parse(String s)
         at MultipleSelection.Models.Sssql01.User.<>c.<get_SelectedLocations>b__13_0(String l) in C:\Dev\MultipleSelection\server\Models\sssql01\User.Custom.cs:line 16

Offending line is:

return Locations != null ? Locations.Split(',').Select(l => int.Parse(l)) : Enumerable.Empty<int>();

How do you handle no selection when the last item is cleared?

Note that when the Locations field is null in the database when the form load selections and save work as they should.

If you try to debug your code you can see that Locations is an empty string. To handle this as well as null you can change the code to:

!string.IsNullOrEmpty(Locations) ? Locations.Split(',').Select(l => int.Parse(l)) : Enumerable.Empty<int>();

Got it I was close to the same solution.

Thank you for teaching me to fish, I will always be able to eat.