Hi,
Please how do you set the selected value on the dropdownlist after a page reload.
eg from the url or setting the value oninitialised.
Selected Value does not set it in code below, even tho the if statement is true.
Please see code below
<SfDropDownList TValue="string" Placeholder="Groups" TItem="Groups" DataSource="@Group" @bind-Value="@SelectedValue">
<DropDownListEvents TItem="Groups" TValue="string" ValueChange="@ValueChangeHandler" ></DropDownListEvents>
<DropDownListFieldSettings Text="Text" Value="Value"></DropDownListFieldSettings>
</SfDropDownList>
@code {
private string SelectedValue { get; set;}
public class Groups
{
public string Text { get; set; }
public string Value { get; set; }
}
List<Groups> Group = new List<Groups>
{
new Groups() { Value = "Group/EE", Text = "EE" },
new Groups() { Value = "Group/Orange", Text = "Orange" },
new Groups() { Value = "Group/T-mobile", Text = "T-mobile" },
};
private void ValueChangeHandler(ChangeEventArgs<string, Groups> args)
{
if(string.IsNullOrEmpty(SelectedValue) == false){
NavigationManager.NavigateTo(SelectedValue, true);
}
}
protected override void OnInitialized()
{
var uri = NavigationManager.ToAbsoluteUri(NavigationManager.Uri);
if (uri.ToString().Contains("EE"))
{
SelectedValue = "EE";
}
}
}