Html.DropDownList
后台
为临颍等地区用户提供了全套网页设计制作服务,及临颍网站建设行业解决方案。主营业务为网站建设、网站设计、临颍网站设计,以传统方式定制建设网站,并提供域名空间备案等一条龙服务,秉承以专业、用心的态度为用户提供真诚的服务。我们深信只要达到每一位用户的要求,就会得到认可,从而选择与我们长期合作。这样,我们也可以走得更远!
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.DropDownList
网页网址:http://azwzsj.com/article/gpjdoh.html