溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊(cè)×
其他方式登錄
點(diǎn)擊 登錄注冊(cè) 即表示同意《億速云用戶(hù)服務(wù)條款》

Html.DropDownList

發(fā)布時(shí)間:2020-05-21 10:44:00 來(lái)源:網(wǎng)絡(luò) 閱讀:900 作者:8218729 欄目:編程語(yǔ)言

后臺(tái)

 List<SelectListItem> Countyitems = new List<SelectListItem>()
            {
                //new SelectListItem(){Text="--請(qǐng)選擇--", Value="",Selected = false},
                new SelectListItem(){Text="欽北區(qū)", Value="0",Selected = true},
                new SelectListItem(){Text="欽南區(qū)", 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="--請(qǐng)選擇--", Value="",Selected = false},
                new SelectListItem(){Text="欽州市", Value="0",Selected = true}

            };

            List<SelectListItem> Provinceitems = new List<SelectListItem>()
            {
                //new SelectListItem(){Text="--請(qǐng)選擇--", 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;


前臺(tái)

<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>


向AI問(wèn)一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI