We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Dropdownlist: Created event wiring

I can't find an example anywhere that shows how to use the Created event of the SfDropDownList. What argument type do I need to use in the Created handler?


<SfDropDownList DataSource="@employees" TItem="Employee" TValue="int" Placeholder="Select an employee" @bind-Value="@(company.EmployeeId)">

<DropDownListFieldSettings Text="Name" Value="Id" />
    <DropDownListEvents Created="CreatedHandler" TItem="Employee" TValue="int" />
</SfDropDownList>

private void CreatedHandler(???)
{
}

1 Reply

SP Sureshkumar P Syncfusion Team March 13, 2023 01:28 PM UTC

Hi Andy,

We have considered supporting “document the Event details with its argument types on dropdownlist component” at our end and this support will be included in any one of our upcoming releases.

Find the argument type for the dropdownlist component here:

@using Syncfusion.Blazor.DropDowns

 

<p>DropDownList value is:<strong>@DropVal</strong></p>

 

<SfDropDownList TValue="string" Placeholder="e.g. Australia" TItem="Country" Width="300px" @bind-Value="@DropVal" DataSource="@Countries">

    <DropDownListFieldSettings Value="Name"></DropDownListFieldSettings>

    <DropDownListEvents Created="CreatedHandler" TItem="Country" TValue="string" />

</SfDropDownList>

 

@code {

    void CreatedHandler(object args)

    {

        // code here

    }

    public string DropVal = "Canada";

 

    public class Country

    {

        public string Name { get; set; }

 

        public string Code { get; set; }

    }

 

    List<Country> Countries = new List<Country>

   {

        new Country() { Name = "Australia", Code = "AU" },

        new Country() { Name = "Bermuda", Code = "BM" },

        new Country() { Name = "Canada", Code = "CA" },

        new Country() { Name = "Cameroon", Code = "CM" },

    };

}

 


Regards,

Sureshkumar P


Loader.
Up arrow icon