Thread ID: |
Created: |
Updated: |
Platform: |
Replies: |
141678 | Dec 27,2018 10:40 AM UTC | Dec 31,2018 12:42 PM UTC | ASP.NET Core - EJ 2 | 1 |
![]() |
Tags: ComboBox |
<code>
public IActionResult Index()
{
ViewBag.data = new Vegetables().VegetablesList();
//ViewBag.sort = "Ascending";
ViewBag.sort = "None";
return View();
}
</code> |
<code>
public class Vegetables
{
public string Vegetable { get; set; }
public string Category { get; set; }
public string Id { get; set; }
public List<Vegetables> VegetablesList()
{
List<Vegetables> veg = new List<Vegetables>();
veg.Add(new Vegetables { Vegetable = "Yarrow", Category = "Leafy and Salad", Id = "item11" });
veg.Add(new Vegetables { Vegetable = "Wheat grass", Category = "Leafy and Salad", Id = "item10" });
veg.Add(new Vegetables { Vegetable = "Cabbage", Category = "Leafy and Salad", Id = "item1" });
veg.Add(new Vegetables { Vegetable = "Chickpea", Category = "Beans", Id = "item2" });
veg.Add(new Vegetables { Vegetable = "Garlic", Category = "Bulb and Stem", Id = "item3" });
veg.Add(new Vegetables { Vegetable = "Green bean", Category = "Beans", Id = "item4" });
veg.Add(new Vegetables { Vegetable = "Horse gram", Category = "Beans", Id = "item5" });
veg.Add(new Vegetables { Vegetable = "Nopal", Category = "Bulb and Stem", Id = "item6" });
veg.Add(new Vegetables { Vegetable = "Onion", Category = "Bulb and Stem", Id = "item7" });
veg.Add(new Vegetables { Vegetable = "Pumpkins", Category = "Leafy and Salad", Id = "item8" });
veg.Add(new Vegetables { Vegetable = "Spinach", Category = "Leafy and Salad", Id = "item9" });
return veg;
}
}
</code> |
<code>
<ejs-dropdownlist id="games" dataSource="@ViewBag.data" placeholder="Select a game" popupHeight="220px" sortOrder="@ViewBag.sort" >
<e-dropdownlist-fields text="Vegetable" value="Id"></e-dropdownlist-fields>
</ejs-dropdownlist>
</code> |
This post will be permanently deleted. Are you sure you want to continue?
Sorry, An error occured while processing your request. Please try again later.
This page will automatically be redirected to the sign-in page in 10 seconds.