I need to know the Id and the value of selected items. as the the following example. so options should have an array of selected parts.
<MudGrid>
<MudItem xs="6" sm="6" md="4">
@* <MudSelect T="string" Label="Parts" Strict="true" MultiSelection="true" Variant="Variant.Outlined" @bind-Value="value" @bind-SelectedValues="options" Margin="Margin.Dense" Required="true" Format="F2">*@
<MudSelect T="string" Label="Parts " HelperText="Pick the Parts" MultiSelection="true" @bind-SelectedValues="options">
@foreach (var part in parts)
{
<MudSelectItem T="string" Value=@part.PartValue>@part.PartValue</MudSelectItem>
}
</MudSelect>
</MudItem>
</MudGrid>
@code {
IEnumerable<Parts> parts = new List<Parts>()
{
new Parts() {PartID = 1, PartValue = "Audi"},
new Parts() {PartID = 2, PartValue = "BMW"},
new Parts() {PartID = 3, PartValue = "Chevrolet"},
new Parts() {PartID = 4, PartValue = "Ferrari"},
new Parts() {PartID = 5, PartValue = "Porsche"},
new Parts() {PartID = 6, PartValue = "Renault"}
};
private int value { get; set; } = 0;
private HashSet<int> options { get; set; } = new HashSet<int>() { 0 };
public class Parts
{
public int PartID { get; set; }
public string PartValue { get; set; }
}
}