-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Closed
Labels
area-blazorIncludes: Blazor, Razor ComponentsIncludes: Blazor, Razor ComponentsenhancementThis issue represents an ask for new feature or an enhancement to an existing oneThis issue represents an ask for new feature or an enhancement to an existing one
Description
I make like that html List in blazor client-side:
<InputSelect @bind-Value="model.ByCountryId" class="form-control">
@if (model?.Countries != null)
{
@foreach (var cnt in model.Countries)
{
<option value="@cnt.Id">@cnt.Name</option>
}
}
</InputSelect>
The code block is like that:
@code {
BrandModel model = new BrandModel();
protected override async Task OnInitializedAsync()
{
model = new BrandModel
{
Id = 19,
ByCountryId = 1,
Countries = new List<ent.Country>
{
new ent.Country { Id = 1, Name = "Azerbaijan" },
new ent.Country { Id = 2, Name = "Turkey" }
},
IsActive = true,
Name = "Brand"
};
}
Model structure is like that:
public class BrandModel
{
public short Id { get; set; }
[Required]
public string Name { get; set; }
[Required]
public byte ByCountryId { get; set; }
public bool IsActive { get; set; }
public IEnumerable<Country> Countries { get; set; }
}
So during the execution of this code, the binding is not working and I get an exception like that:
WASM: System.InvalidOperationException: Microsoft.AspNetCore.Components.Forms.InputSelect 1[System.Byte] does not support the type 'System.Byte'
Question is: How can I bind, byte value in blazor? Thanks in advance!
villainoustourist
Metadata
Metadata
Assignees
Labels
area-blazorIncludes: Blazor, Razor ComponentsIncludes: Blazor, Razor ComponentsenhancementThis issue represents an ask for new feature or an enhancement to an existing oneThis issue represents an ask for new feature or an enhancement to an existing one