aspnetcore: Cannot bind to nullable types (bool?, int?, etc)
A lot of work has been done for the bind method, let’s add the one for nullable bool. bool?
Current error: Uncaught (in promise) Error: System.ArgumentException: ‘bind’ does not accept values of type System.Nullable`1[[System.Boolean, mscorlib, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]]. To read and write this value type, wrap it in a property of type string with suitable getters and setters.
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Comments: 16 (6 by maintainers)
@SteveSandersonMS
The UI state is “empty” - the initial state. For example when you
bindan<input type="number">toint?which is currentlynullthe input should stay empty.I believe both React and Angular behave in a similar way.
In my opinion it is a must have feature. Hopefully @SteveSandersonMS will agree.
So, will we allow nullables? If so i’ll see if I can implement the others as well in #1012
Thanks for contacting us. We think that this issue is fixed now. If you are still facing this problem, please file a new issue.
Supporting
DateTime?is also needed for<input type="date">and<input type="datetime-local">A nullable bool should show nothing, but it is usefull when you want to bind the value, like we’re doing here If the checkbox is interacted with, it should be true or false but initially it should be nothing.