Articles in this section
Category / Section

How to add the Blazor ComboBox ValueChange handler an additional parameter?

3 mins read

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

 

In the code example below, an additional parameter is passed by writing a lambda expression for the ValueChange event handler and calling the OnChange method with this 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)
{
 
}
}
 

 Conclusion

We hope you enjoyed learning about how to add the Blazor ComboBox ValueChange handler an additional parameter.

You can refer to our Blazor ComboBox feature tour page to know about its other groundbreaking features, documentation, and how to quickly get started with configuration specifications. You can also explore our Blazor ComboBox example to understand how to create and manipulate data in the Blazor ComboBox.

For current customers, our Blazor components are available on the License and Downloads page. If you are new to Syncfusion, you can try our 30-day free trial to evaluate our Blazor ComboBox and other Blazor components.

If you have any questions or require clarifications, please let us know in the comments section below. You can also contact us through our support forumsDirect-Trac, or feedback portal. We are always happy to assist you!


 

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Please  to leave a comment
Access denied
Access denied