0
现在我已经在身份加入一个地区到ApplicationUser模型2.0EditUserViewModel需要DropDownListFor()
在UsersAdmin查看,编辑动作,我有以下的股票代码来显示/编辑用户的地区:
<div class="form-group">
@Html.LabelFor(model => model.Region, new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.TextBoxFor(m => m.Region, new { @class = "form-control" })
</div>
</div>
如何使该文本框到一个DropDownList,允许用户从区域名称的列表,其中地区是ApplicationDbContext的一部分选择呢?
public class Region
{
[Key]
public Guid ID { get; set; }
public string Name { get; set; }
public Company Company { get; set; }
public Region()
{
this.ID = Guid.NewGuid();
}
}
一个后续的问题:WH我从DropDownList中选择一个选区,然后在此EditView上单击Save,将MyViewModel交还给Task Edit为SelectedRegionId具有全零。我如何让用户选择区域回控制器? –
davecove
2014-09-28 18:18:52
当您提交表单时,您能否看到发送到服务器的实际有效负载?它看起来怎样? – 2014-09-28 18:20:39
我该怎么做? (使用带内置本地主机的VS2013) – davecove 2014-09-28 18:23:40