1

我试图为我创建的模块获取一个列表框。选择器有效(可选实体的标题出现,但没有数据返回到控制器中的 Post 函数。

我不知道你需要什么才能帮助我,但这里至少是 html 代码。

HTML 代码:

    <div class="field required">
        @Html.LabelFor(model => model.Sessions)
        @Html.ListBox("Sessions", new SelectList(Model.Sessions, "Id", "Title", 1));
        @Html.ValidationMessageFor(model => model.Sessions)
    </div>
4

1 回答 1

0

用于ViewBag_Controller

ViewBag.Sessions = new SelectList(EntityName, "Id", "Name", entity.ID);    

entity.ID将是您要选择的值

@Html.DropDownList("Sessions", "Select Sessions")
于 2012-09-07T08:08:23.090 回答