Thread ID: |
Created: |
Updated: |
Platform: |
Replies: |
150143 | Dec 23,2019 01:42 AM UTC | Dec 24,2019 11:13 AM UTC | ASP.NET Core - EJ 2 | 3 |
![]() |
Tags: Dropdown List |
<ejs-dropdownlist id="Countries" ejs-for="Value" dataSource="@ViewBag.data" placeholder="Select a Country" popupHeight="220px">
<e-dropdownlist-fields text="Country.CountryId" value="Code.Id"></e-dropdownlist-fields>
</ejs-dropdownlist> |
public IActionResult Index()
{
ViewBag.data = new Complex().GetData();
model.Value = "AU";
return View(model);
}
public class Code
{
public string Id { get; set; }
}
public class Country
{
public string CountryId { get; set; }
}
public class modelValue
{
public string Value { get; set; }
}
public class Complex
{
public Country Country { get; set; }
public Code Code { get; set; }
public List<Complex> GetData()
{
List<Complex> data = new List<Complex>();
data.Add(new Complex() { Country = new Country() { CountryId = "Australia" }, Code = new Code() { Id = "AU" } });
data.Add(new Complex() { Country = new Country() { CountryId = "Bermuda" }, Code = new Code() { Id = "BM" } });
data.Add(new Complex() { Country = new Country() { CountryId = "Canada" }, Code = new Code() { Id = "CA" } });
data.Add(new Complex() { Country = new Country() { CountryId = "Cameroon" }, Code = new Code() { Id = "CM" } });
data.Add(new Complex() { Country = new Country() { CountryId = "Denmark" }, Code = new Code() { Id = "DK" } });
data.Add(new Complex() { Country = new Country() { CountryId = "France" }, Code = new Code() { Id = "FR" } });
return data;
}
} |
@{
var select = new SelectList((IEnumerable<WebApplication1.Controllers.HomeController.Dictionaryy>)ViewData["Regions"], "ID", "Title");
}
<ejs-dropdownlist id="Countries" dataSource=select.Items placeholder="Select a Country" popupHeight="220px">
<e-dropdownlist-fields text='Title' value='ID'></e-dropdownlist-fields>
</ejs-dropdownlist> |
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.