Html.DropDownList_html/css_WEB-ITnose
程序员文章站
2022-05-17 21:53:13
...
后台
ListCountyitems = new List () { //new SelectListItem(){Text="--请选择--", Value="",Selected = false}, new SelectListItem(){Text="钦北区", Value="0",Selected = true}, new SelectListItem(){Text="钦南区", Value="1",Selected = false}, new SelectListItem(){Text="灵山县", Value="2",Selected = false}, new SelectListItem(){Text="浦北县", Value="3",Selected = false}, }; List Cityitems = new List () { //new SelectListItem(){Text="--请选择--", Value="",Selected = false}, new SelectListItem(){Text="钦州市", Value="0",Selected = true} }; List Provinceitems = new List () { //new SelectListItem(){Text="--请选择--", Value="",Selected = false}, new SelectListItem(){Text="广西省", Value="0",Selected = true} }; SelectList CountyList = new SelectList(Countyitems, "Value", "Text", 0); SelectList CityList = new SelectList(Cityitems, "Value", "Text", 0); SelectList ProvinceList = new SelectList(Provinceitems, "Value", "Text", 0); ViewData["County"] = CountyList; ViewData["City"] = CityList; ViewData["Province"] = ProvinceList;
前台
@Html.LabelFor(m => m.Province) @Html.DropDownList("Province", ViewData["Province"] as SelectList, new { style = "width:153px" }) @Html.ValidationMessageFor(m => m.Province) @Html.LabelFor(m => m.City) @*@Html.TextBoxFor(m => m.City)*@ @Html.DropDownList("City", ViewData["City"] as SelectList, new { style = "width:153px" }) @Html.ValidationMessageFor(m => m.City) @Html.LabelFor(m => m.County) @*@Html.TextBoxFor(m => m.County)*@ @Html.DropDownList("County", ViewData["County"] as SelectList, new { style = "width:153px" }) @Html.ValidationMessageFor(m => m.County)
推荐阅读
-
关于网页路径的疑惑_html/css_WEB-ITnose
-
Codeforces Round #156 (Div. 2)-A. Greg's Workout_html/css_WEB-ITnose
-
html 关于ul标签的_html/css_WEB-ITnose
-
background-size 设置背景图片的大小_html/css_WEB-ITnose
-
multiple backgrounds 多重背景_html/css_WEB-ITnose
-
建站新人_html/css_WEB-ITnose
-
折线图怎么做啊?急求!_html/css_WEB-ITnose
-
Codeforces Round #107 (Div. 2)-A. Soft Drinking_html/css_WEB-ITnose
-
css5种实现垂直居中_html/css_WEB-ITnose
-
求解如何在表格边框中设置颜色_html/css_WEB-ITnose