Use MVC dropdownlist, mvcdropdownlist
View code
@ {ViewBag. title = "dropdownlist" ;}< h2> dropdownlist
Code in Control
Public ActionResult dropdownlist () {var q = from p in modeltest. students select p; List <student> droptest = q. toList (); SelectList selList1 = new SelectList (droptest, "id", "name"); ViewBag. selList1 = selList1.AsEnumerable (); // select the database data binding return View ();} [HttpPost] public ActionResult dropdownlist (string test = "test ") {var q = from p in modeltest. students select p; List <student> droptest = q. toList (); ViewData ["name"] = new SelectList (droptest, "id", "name"); // refactor dropdownlist var name = modeltest. students. find (Convert. toInt32 (Request. form ["name"]); formtest fm = new formtest {id = Convert. toInt32 (Request. form ["1"]), value1 = Request. form ["sex"], value2 = name. name}; // assign modeltest to the model object through the data in the view. formtest. add (fm); modeltest. saveChanges (); return View (fm );}