Articles in this section
Category / Section

How to return the model value of DropDownList to the controller using scaffolding method?

2 mins read


Strongly-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. 


The 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.

  1. Create the model for your requirement.


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;


  1. Create an action method that renders UI on the view page, and passes the model to be bound to the view page.


public ActionResult DropdownlistFeatures()
            DropDownListModel model = new DropDownListModel();
            model.DropData = "E11011";
            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;


  1. Create a strong typed view based on your model.



@Html.EJ().DropDownListFor(Model => Model.DropData, (Syncfusion.JavaScript.Models.DropDownListProperties)ViewData["properties"])


  1. Create an action method, FormPost that handles the Post request and processes the data. In the action method, you can pass a model as the parameter. That model has UI input field data.


public ActionResult FormPost(DropDownListModel model)
        return View();


  1. Select the values from the EJ form controls and post the form. You can get the selected values in the post action from the model as follows.


Return model value using scaffolding method


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