首页新闻找找看学习计划

@Html.DropDownList 提交后台如何获取值?求大师指点。我取到的值为空,不懂了。

0
悬赏园豆:5 [待解决问题]

前台:

               <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);
        }

ZhengSheng的主页 ZhengSheng | 初学一级 | 园豆:179
提问于:2012-08-31 16:50
< >
分享
所有回答(2)
0

这个应该通过model binding 来进行数据的传递的

chenping2008 | 园豆:9836 (大侠五级) | 2012-08-31 22:32
0

request["PublisherID"].text()

Tryi | 园豆:7 (初学一级) | 2012-09-03 11:57
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册