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
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to pass an extra parameter to Blazor ComboBox ValueChange handler?

Platform: Blazor |
Control: Dropdown List

This article explains how to pass an extra parameter to ValueChange event handler of Blazor ComboBox.

 

In the below code example, additional parameter passed by writing lamda expression for ValueChange event handler and called OnChange method with additional parameter.

RAZOR

@using Syncfusion.Blazor.DropDowns
 
<SfComboBox ID="ComboBox1" TValue="string" TItem="GameFields" PopupHeight="230px" Placeholder="Select a game" DataSource="@Games">
<ComboBoxEvents TValue="string" TItem="GameFields" ValueChange='((e) => OnChange(e, "ComboBox1"))'/>
<ComboBoxFieldSettings Text="Text" Value="ID" />
</SfComboBox>
 
<SfComboBox ID="ComboBox2" TValue="string" TItem="GameFields" PopupHeight="230px" Placeholder="Select a game" DataSource="@Games">
<ComboBoxEvents TValue="string" TItem="GameFields" ValueChange='((e) => OnChange(e, "ComboBox2"))' />
<ComboBoxFieldSettings Text="Text" Value="ID" />
</SfComboBox>
 
 
@code {
public class GameFields
{
public string ID { get; set; }
public string Text { get; set; }
}
private List<GameFields> Games = new List<GameFields>()
{
new GameFields(){ ID= "Game1", Text= "American Football" },
new GameFields(){ ID= "Game2", Text= "Badminton" },
new GameFields(){ ID= "Game3", Text= "Basketball" },
new GameFields(){ ID= "Game4", Text= "Cricket" },
new GameFields(){ ID= "Game5", Text= "Football" },
new GameFields(){ ID= "Game6", Text= "Golf" },
new GameFields(){ ID= "Game7", Text= "Hockey" },
new GameFields(){ ID= "Game8", Text= "Rugby"},
new GameFields(){ ID= "Game9", Text= "Snooker" },
new GameFields(){ ID= "Game10", Text= "Tennis"}
};
 
public void OnChange(Syncfusion.Blazor.DropDowns.ChangeEventArgs<string, GameFields> args, string id)
{
 
}
}
 

 

View Sample in GitHub

Refer to our documentation and online samples for more features. If you have any queries, please let us   know in the comments below. You can also contact us through our Support forum or Support ticket. We are happy to assist you!

 

ADD COMMENT
You must log in to leave a comment

Please sign in to access our KB

This page will automatically be redirected to the sign-in page in 10 seconds.

Up arrow icon

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile