Hi,
I have dropdown list that is bound to an IEnumerable retireved from a DB. The value that should be selected from the list is retreived in a second query. If the second query is Async then setting the selection fails. If the second query is not async it works fine. This looks pretty similar to an ThreadId 148929.
<SfDropDownList TValue="int?" DataSource="DashBoards" Width="200px" TItem="DashBoard" Value="DashBoardId" @ref="ddlDashBoards">
<DropDownListFieldSettings Value="DashBoardId" Text="Name"></DropDownListFieldSettings>
<DropDownListEvents OnValueSelect="OnValueSelectDashBoardListAsync" TValue="int?" TItem="DashBoard"></DropDownListEvents>
<DropDownListTemplates TItem="DashBoard">
<!-- Templated to allow the inclusion of the shared icon -->
<ItemTemplate>
@{
var DashBoardObj = (context as DashBoard);
if (DashBoardObj != null)
{
if (DashBoardObj.AccessType == DashBoardAccess.Access.Shared)
{
<span class="vx-icon-share"></span>
<span>@DashBoardObj.Name</span>
}
else
{
<span style="padding-left:27px;">@DashBoardObj.Name</span>
}
}
}
</ItemTemplate>
<ValueTemplate>
@{
var DashBoardObj = (context as DashBoard);
if (DashBoardObj != null)
{
if (DashBoardObj.AccessType == DashBoardAccess.Access.Shared)
{
<div style="margin-top: 4px; margin-left: 8px;">
<span class="vx-icon-share"></span>
<span>@DashBoardObj.Name</span>
</div>
}
else
{
<div style="margin-top: 5px; margin-left: 8px;">
@DashBoardObj.Name
</div>
}
}
}
</ValueTemplate>
</DropDownListTemplates>
</SfDropDownList>
protected override async Task OnInitializedAsync()
{
this.DashBoards = await this.DashBoardRepositoryObj.GetDashBoardsAsync();
// Get the last selected dashboard. If its null (first time in) or its been delete then use default vale
// UserPreference UserPreferenceObj = await this.UserRepositoryObj.GetUserPreferenceAsync(UserPreference.DASHBOARDSELECTED, ApplicationConfigurationObj.LoggedUserId);
UserPreference UserPreferenceObj = this.UserRepositoryObj.GetUserPreference(UserPreference.DASHBOARDSELECTED, ApplicationConfigurationObj.LoggedUserId);
if (UserPreferenceObj.NumericValue != null && (this.DashBoards.FirstOrDefault<DashBoard>((DashBoard x) => x.DashBoardId == UserPreferenceObj.NumericValue) != null))
this.DashBoardId = UserPreferenceObj.NumericValue;
else
// Make the first Dashboard in the list the selected one
this.DashBoardId = this.DashBoards.First<DashBoard>().DashBoardId;
}
Regards,
Mike