标签:
public ActionResult Index() { ViewBag.sh = "123"; List<SelectListItem> list = new List<SelectListItem>(); list.Add(new SelectListItem() { Selected = false, Text = "济南", Value = "1", }); list.Add(new SelectListItem() { Selected = false, Text = "青岛", Value = "2", }); ViewBag.ddlData = list; return View(); }
★视图中的绑定代码如下:注意自动绑定的前提
@Html.DropDownList("ddlData")
★行为的重载的前提条件,代码如下:
//行为的重载,满足两点要求1.行为的名字必须相同2.签名不相同3.http请求不同,默认是[HttpGet] [HttpPost] public ActionResult TianJiaPerson(Person p1) { ViewData.Model = p1; return View("TianJiaPerson1"); }
标签:
原文地址:http://www.cnblogs.com/gchlcc/p/4913438.html