I use Blazor WASM .NET Standard 2.1 and Radzen library for my components. The client can choose measure type from the Razden dropdown, the problem is when I want to edit this product the dropdown did not populate with the correct measure but with first from enum.
<RadzenDropDown @bind-Value="@model.Measure"
AllowClear="true"
Placeholder="Избери категория..."
Data="@MyTypes" style="width: 100%;"
TextProperty="EnumName"
ValueProperty="EnumValue"
Name="Measure">
</RadzenDropDown>
public enum Measure
{
part,
kilogram,
gram
}
public class EnumMyTypes
{
public Measure EnumValue { get; set; }
public string EnumName { get; set; }
}
// list for the dropdown
List<EnumMyTypes> MyTypes { get; set; } = new List<EnumMyTypes>();
protected override async Task OnInitializedAsync()
{
this.model = await this.ProductsService.DetailsAsync<ProductsRequestModel>(this.Id);
this.categories = await this.CategoriesService.All();
foreach (var item in Enum.GetValues(typeof(Measure)))
{
MyTypes.Add(new EnumMyTypes { EnumName = item.ToString(), EnumValue = (Measure)item });
}
}