前台:
<tr>
<td>
图书出版社:
</td>
<td>
@Html.DropDownList("PublisherID", String.Empty)
@Html.ValidationMessageFor(m => m.Publisher)
</td>
</tr>
后台:
[HttpPost]
public ActionResult CreateComfirmed(MVC_Login.Models.Book book)
{
ViewBag.PublisherID = new SelectList(db.Publishers, "PublisherID", "PublisherTitle");
if (ModelState.IsValid)
{
db.Books.Add(book);
db.SaveChanges();
return RedirectToAction("Index");
}
return View(book);
}
这个应该通过model binding 来进行数据的传递的
request["PublisherID"].text()