下拉列表 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>

posted @ 2014-03-11 17:12  gitran  阅读(226)  评论(1编辑  收藏  举报