I'm pretty new to Blazor/Radzen environment and I know I'm not the sharpest clam in the bucket but I still can't figure this out. In all the sample code I could find it didn't seem like the OnChange event needed to do anything to set the SelectedText other than invoking StateHasChanged
I have a List of Properties, the two important fields are string WAddressDisplay and double PropID.
The Dropdown populates perfectly. I can select the item I want and the OnChange fires perfectly but the selection doesn't show up in the Dropdown selection. I know the item is properly selected because the OnChange returns the correct item.
Here's my HTML for the dropdown
<RadzenDropDown AllowClear="true" TValue="string"
Name="pAddress" AllowFiltering="true"
@bind-Value=@boundValue
Data=@PropertyList
TextProperty="WAddressDisplay"
ValueProperty="PropID"
Change=@(args => OnChange(args, "newAddress")) Class="w-100">
</RadzenDropDown>
Here is my OnChange
double boundValue = 0;
...
void OnChange(object value, string name)
{
var str = value is IEnumerable<object> ? string.Join(", ", (IEnumerable<object>)value) : value;
if (name == "newAddress")
{
if (str != null)
{
propertyLink = boundValue;
buttonOKDisabled = false;
InvokeAsync(StateHasChanged);
}
else
{
boundValue = 0;
propertyLink = "";
buttonOKDisabled = true;
}
}
}
This is my PropertyDTO (abbreviated)
public class PropertyLookupDto
{
public int Id { get; set; }
[Required]
[StringLength(4)]
public string Town { get; set; } = null!;
public double PropId { get; set; }
[StringLength(40)]
public string WAddressDisplay { get; set; }
}
Selecting an item:
Results after selecting an item:
OK button has been enabled and the PropID has been properly selected, it's just the selected text is still blank