我在我的控制员(为埃德特和创建)中有以下守则:
model.Templates = new SelectList(PageManagementService.PageTemplateFetchList(), "PageId", "Title", 213);
“213”是一页的Id,只是用于测试。
我认为(为Edit和创建):
<%= this.Html.DropDownListFor(model => model.Page.TemplateId, this.Model.Templates)%>
<%= this.Model.Templates.SelectedValue %>
When I go to the Create form, I see the dropdown list, but the tag with value="213" is not selected. I even output the SelectedValue to make sure it s 213 - and I see 213.
When I go to the Edit form, I see the dropdown list, and the tag with value="213" is selected.
On the Create form, none of the tags have a "selected" attribute.
On the Edit form, the tag with value="213" has the "selected" attribute.
我失踪了吗? 怎样才能做到这一点? 没有人会看到这种行为?
<><>UPDATE: 改变除名名单的名称,使其发挥作用。 例如,而不是
<%= this.Html.DropDownListFor(model => model.Page.TemplateId, this.Model.Templates)%>
我这样做了。
<%= this.Html.DropDownList("somedropdown", this.Model.Templates)%>
它发挥了作用。 不清楚为什么......