2X faster development
The ultimate ASP.NET MVC UI toolkit to boost your development speed.
DescriptionStrongly-Typed HTML Helper: The DropDownList control supports strongly typed HTML helpers represented by lambda expressions that have model or template passed into the View. The Extension method is used to get a value from the model. SolutionThe DropDownListFor takes lambda as a parameter that tells the helper with element of the model to use in the typed view. This enables the better compile-time checking of the views that allow you to find errors at build-time instead of at runtime, and also enables better code intelligence support within the view templates. The following steps explain how to get the values by using the Scaffolding methods.
C# public class DropDownListModel { public List<Employee> DropData { get; set; } } public class Employee { public string name { set; get; } public string empID { set; get; } public string desgination { set; get; } public Employee(string ename, string eid, string edesg) { name = ename; empID = eid; desgination = edesg; } }
C# public ActionResult DropdownlistFeatures() { DropDownListModel model = new DropDownListModel(); model.DropData = "E11011"; BindingData(); return View(model); } public void BindingData() { List<Employee> data = new List<Employee>() { }; data.Add(new Employee("Nancy", "E11011", "Technical Writer")); data.Add(new Employee("Angel", "E11012", "Professor")); data.Add(new Employee("Daniah", "E11013", "Dancer")); data.Add(new Employee("Jenifer", "E11014", "Beautician")); data.Add(new Employee("Prince", "E11015", "Developer")); DropDownListProperties ddl = new DropDownListProperties(); ddl.DataSource = data; DropDownListFields ddf = new DropDownListFields(); ddf.Text = "name"; ddf.Value = "empID"; ddl.DropDownListFields = ddf; ViewData["properties"] = ddl; }
C#
@Html.EJ().DropDownListFor(Model => Model.DropData, (Syncfusion.JavaScript.Models.DropDownListProperties)ViewData["properties"])
C# public ActionResult FormPost(DropDownListModel model) { return View(); }
|
2X faster development
The ultimate ASP.NET MVC UI toolkit to boost your development speed.
This page will automatically be redirected to the sign-in page in 10 seconds.