DropDownList Cleared event?

What is the relevant event for selection cleared by Clear button? I don't see Cleared event like MultiSelect control.


<SfDropDownList @bind-Value="@_runNumber" TValue=string TItem=string Placeholder="Run #" FloatLabelType="FloatLabelType.Always" DataSource="@_runNumbers" ShowClearButton="true" title="Select a test method run number if exists.">

    <DropDownListEvents TItem="string" TValue="string" OnValueSelect="@OnRunNumberSelected"></DropDownListEvents>

</SfDropDownList>

    private string? _runNumber;

    private List<string> _runNumbers = new List<string>() { "01", "02", "03", "04", "05" };



1 Reply

YA YuvanShankar Arunagiri Syncfusion Team June 25, 2025 08:04 AM UTC

Hi Yongkee,


Query: What is the relevant event for selection cleared by Clear button?


Use the ValueChange event of Dropdown List component for capturing the cleared action in Dropdown List component. Refer to the below code snippet and attach sample code file.


<SfDropDownList @bind-Value="@_runNumber" TValue=string TItem=string Placeholder="Run #" FloatLabelType="FloatLabelType.Always" DataSource="@_runNumbers" ShowClearButton="true" title="Select a test method run number if exists.">

    <DropDownListEvents TItem="string" TValue="string" OnValueSelect="@OnRunNumberSelected" ValueChange="OnChange"></DropDownListEvents>

</SfDropDownList>

 

@code{

…….

    private void OnChange(ChangeEventArgs<string, string> args)

    {

        if (args.IsInteracted && args.Value == null)

        {

            // here you can handle the cleared action

        }

    }

}


Query: I don't see Cleared event like MultiSelect control?


There is a component structural behavior difference between the Dropdown List and Multi Select components. In the Multi Select component, we have a multi-selection option, but in our dropdown list, we have a single selection alone. Due to this reason, we have provided the Cleared event for the Multi Select component and handle the cleared action in the ValueChange event itself for the Dropdown List component.


Regards,

YuvanShankar A


Attachment: Home_6f29d9ff.zip

Loader.
Up arrow icon