DropDownList
Controller中设置
{
(new SelectListItem() {Text = "001", Value = "1", Selected =false}),
(new SelectListItem() {Text = "002", Value = "2", Selected =false})
};
View中使用
@Html.DropDownList("items")
RadioButton
lRadioButton第一个参数为控件名字(名字相同说明为同一个Group),返回值为第二个参数(红色部分)
男 @Html.RadioButton("gender", "1", true)
女 @ Html.RadioButton("gender", "0“, false)
本文介绍如何在ASP.NET MVC中使用DropDownList和RadioButton。具体包括:在Controller中设置DropDownList选项并通过ViewBag传递到视图的方法,以及RadioButton的基本用法和参数说明。
3万+

被折叠的 条评论
为什么被折叠?



