I want to use a <select> to be able to choose between several values, or choose none.
My component is this one :
<select @bind="SelectedValue">
<option value="null">Null</option>
@for (int i = 0; i < 10; i++)
{
<option value="@i">Value : @i </option>
}
</select>
<hr />
@if (SelectedValue.HasValue)
{
<p>The selected value is : @SelectedValue.Value</p>
}
else
{
<p>the value is null</p>
}
@code {
private int? SelectedValue = null;
}
I can bind the <select> value to an int object, but I can't bind the null value. Is there a special syntax I should use, or is it just not supported ?