-1

I am a beginner to MVC and now i would like to use Drop down in the form? i have tried using the Dropdownlistfor but it not working properly do we need any additional scripts for this.

2 Answers2

0

does drop down has dynamic/Database value? Yes? As a first step, you need to have a model property which has the drop down values, something like

 public List<States> StatesDDL
{ get; set;} // get the list of values here.

Static drop down? use the plain HTML

<select id="_ddlStates">
<option></option>...
</select>

good luck...

Ashwath
  • 407
  • 3
  • 10
0

In the the action method of your controller, you have to set a viewbag which is filled with list.

ViewBag.StudentID = new SelectList(db.Students, "StudentID", "Name");

And in the View just use the DropDownList Html Helper

@Html.DropDownList("StudentID", String.Empty)
Pratik Bhoir
  • 2,074
  • 7
  • 19
  • 36