Html.DropDownList_html/css_WEB-ITnose

WBOY
發布: 2016-06-21 08:51:49
原創
1364 人瀏覽過

后台

 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>
登入後複製


相關標籤:
來源:php.cn
本網站聲明
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn
熱門教學
更多>
最新下載
更多>
網站特效
網站源碼
網站素材
前端模板
關於我們 免責聲明 Sitemap
PHP中文網:公益線上PHP培訓,幫助PHP學習者快速成長!