Name
Description
Category:
@foreach (var category in Categories)
{
@category.Name
}
@code {
[SupplyParameterFromForm]
public SegmentModel segment { get; set; } = new();
public int SelectedCategoryId { get; set; }
[Parameter]
public List Categories { get; set; } = new();
protected override async Task OnInitializedAsync()
{
Categories = await manager._categoryRepository.GetAllCategoriesAsync();
}
private async Task HandleSubmit()
{
// await manager._categoryRepository.AddCategoryAsync(Category);
segment.CategoryId = SelectedCategoryId;
await manager._segmentRepository.AddSegmentAsync(segment);
}
private void HandleCategorySelection(ChangeEventArgs args)
{
// Parse the selected value from the event args
int selectedId = Convert.ToInt32(args.Value);
// Set the SelectedCategoryId
SelectedCategoryId = selectedId;
}
}
Tried to bind the id of the selected option in the input select to an integer but it is always set to 0. The categories are initialized properly and the segment itself when i create it is also initialized properly.
private void HandleCategorySelection(ChangeEventArgs args) { // Parse the selected value from the event args int selectedId = Convert.ToInt32(args.Value);
// Set the SelectedCategoryId SelectedCategoryId = selectedId; } } [/code] Tried to bind the id of the selected option in the input select to an integer but it is always set to 0. The categories are initialized properly and the segment itself when i create it is also initialized properly.