下拉列表 MVC DropDownList

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

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

原文地址:https://www.cnblogs.com/gitran/p/3594399.html