在我看来,我试图利用从名单上删除的作者(用户)名单。 我能够把这一下降集中起来,并看到我的看法的内容。 我在提交我的表格时,在我的控制员中和在检查我的模型时,我不敢行动,与我的下降有关的实地价值就是无效的。
Here is my action controller (before showing my view):
public ActionResult Create()
{
IEnumerable<User> authors = m_AccountBusiness.GetAllUsers();
PageCreateViewModel viewModel = new PageCreateViewModel
{
PageToCreate = new PageFullViewModel(),
Authors = authors.Select(x => new SelectListItem { Text = x.UserName, Value = x.UserID.ToString() })
};
return View(viewModel);
}
下面是(部分)我的看法:
@model MyBlog.ViewModels.PageCreateViewModel
<h3>Create</h3>
@using (Html.BeginForm())
{
@Html.ValidationSummary(true)
@Html.HiddenFor(model => model.PageToCreate.PageID)
<div class="editor-label">
@Html.LabelFor(model => model.PageToCreate.Title)
</div>
<div class="editor-field">
@Html.TextBoxFor(model => model.PageToCreate.Title, new { @class = "titleValue" })
@Html.ValidationMessageFor(model => model.PageToCreate.Title)
</div>
<div class="editor-label">
@Html.LabelFor(model => model.PageToCreate.Author)
</div>
<div class="editor-field">
@Html.DropDownListFor(model => model.PageToCreate.Author, Model.Authors, "Please select...")
</div>
我的《意见》是:
public class PageCreateViewModel
{
public PageFullViewModel PageToCreate { get; set; }
public IEnumerable<SelectListItem> Authors { get; set; }
}
任何想法?
感谢。