Quantcast
Channel: Active questions tagged blazor - Stack Overflow
Viewing all articles
Browse latest Browse all 4839

Setting an option to selected in a drop down in Blazor

$
0
0

I have a Telerik grid and am using inline editing. On edit, I have a select dropdown list for the user to select the option that he needs. In my view model if the user is in edit mode I would like for the drop down to have the selected value. It doesn't seem to work properly. Here is the column in my grid:

<GridColumn Field=@nameof(JobAssignmentListViewModel.Trade) Title="Trade" FieldType="@typeof(string)"><EditorTemplate><select id="tradeList" class="form-select" value="@(context as JobAssignmentListViewModel).TradeId" @onchange="@(e => UpdateTradeAsync((JobAssignmentListViewModel)context, e))">                            @foreach (var trade in trades)                            {                                var isSelected = trade.Id == (context as JobAssignmentListViewModel)?.TradeId;<option value="@trade.Id" selected="@isSelected">@trade.Name</option>                            }</select></EditorTemplate></GridColumn>

This just renders selected="" in the HTML when inspected. Is there a way to select the default option in Blazor for a dropdown?


Viewing all articles
Browse latest Browse all 4839

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>