您好,登錄后才能下訂單哦!
后臺
List<SelectListItem> Countyitems = new List<SelectListItem>() { //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<SelectListItem> Cityitems = new List<SelectListItem>() { //new SelectListItem(){Text="--請選擇--", Value="",Selected = false}, new SelectListItem(){Text="欽州市", Value="0",Selected = true} }; List<SelectListItem> Provinceitems = new List<SelectListItem>() { //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;
前臺
<tr> <td>@Html.LabelFor(m => m.Province)</td> <td> @Html.DropDownList("Province", ViewData["Province"] as SelectList, new { style = "width:153px" }) @Html.ValidationMessageFor(m => m.Province) </td> </tr> <tr> <td> @Html.LabelFor(m => m.City)</td> <td> @*@Html.TextBoxFor(m => m.City)*@ @Html.DropDownList("City", ViewData["City"] as SelectList, new { style = "width:153px" }) @Html.ValidationMessageFor(m => m.City) </td> </tr> <tr> <td>@Html.LabelFor(m => m.County)</td> <td> @*@Html.TextBoxFor(m => m.County)*@ @Html.DropDownList("County", ViewData["County"] as SelectList, new { style = "width:153px" }) @Html.ValidationMessageFor(m => m.County) </td> </tr>
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。