下拉列表 MVC DropDownList

ViewBag.CategoryId = new SelectList(db.Categories, "Id", "Name","默認值");it

        <div class="editor-label">
            @Html.LabelFor(model => model.CategoryId, "Category")
        </div>
        <div class="editor-field">
            @Html.DropDownList("CategoryId", String.Empty)
            @Html.ValidationMessageFor(model => model.CategoryId)
        </div>io

相關文章
相關標籤/搜索