<div>
<EjsDropDownList @ref="@DropDownObj" Placeholder="Select a game" DataSource="@LocalData">
<DropDownListFieldSettings Value="ID" Text="Text"></DropDownListFieldSettings>
</EjsDropDownList>
</div>
<div>
<input type="button" value="AddItem" onclick="@AddItems" />
</div>
@code {
EjsDropDownList DropDownObj;
public class Games
{
public string ID { get; set; }
public string Text { get; set; }
}
List<Games> LocalData = new List<Games> {
new Games() { ID= "Game1", Text= "American Football" },
new Games() { ID= "Game2", Text= "Badminton" },
new Games() { ID= "Game3", Text= "Basketball" },
new Games() { ID= "Game4", Text= "Cricket" }
};
public List<Games> Item = new List<Games>{
new Games() { ID= "Game6", Text= "Golf" }
};
public void AddItems()
{
this.DropDownObj.AddItem(Item);
}
} |
@using System.Collections.ObjectModel;
<div>
<EjsDropDownList Placeholder="Select a game" DataSource="@LocalData" TValue="string">
<DropDownListFieldSettings Value="ID" Text="Text"></DropDownListFieldSettings>
</EjsDropDownList>
</div>
<div>
<input type="button" value="AddItem" onclick="@AddItems" />
</div>
@code {
public class Games
{
public string ID { get; set; }
public string Text { get; set; }
}
ObservableCollection<Games> LocalData = new ObservableCollection<Games> {
new Games() { ID= "Game1", Text= "American Football" },
new Games() { ID= "Game2", Text= "Badminton" },
new Games() { ID= "Game3", Text= "Basketball" },
new Games() { ID= "Game4", Text= "Cricket" }
};
public void AddItems()
{
this.LocalData.Add(new Games() { ID= "Game6", Text= "Golf" });
}
} |