MVC代码片段备忘录

MSDN的MVC文档链接,http://msdn.microsoft.com/en-us/library/dd394709.aspx

 

Both the DropDownList and ListBox helpers accept either a SelectList or MultiSelectList object.

List<string> petList = new List<string>();
petList.Add("Dog");
petList.Add("Cat");
petList.Add("Hamster");
petList.Add("Parrot");
petList.Add("Gold fish");
petList.Add("Mountain lion");
petList.Add("Elephant");

ViewData["Pets"] = new SelectList(petList);

<%= Html.DropDownList("pets") %>

posted @ 2009-04-20 13:44  asp.net初学者  阅读(302)  评论(0编辑  收藏  举报