Skip to content

InputSelect is not binding for byte in Blazor  #15256

@embayyub

Description

@embayyub

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!

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-blazorIncludes: Blazor, Razor ComponentsenhancementThis issue represents an ask for new feature or an enhancement to an existing one

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions