[英]Fill EditorFor Field
I'm trying to fill a editorfor field with a default value. 我正在尝试使用默认值填充editorfor字段。 Please help
请帮忙
My Code: 我的代码:
<div class="editor-label">
@Html.LabelFor(model => model.Country)
</div>
<div class="editor-field">
@Html.EditorFor(model => model.Country)
</div>
The model is created by entity framework throughmy SQL database. 该模型由实体框架通过我的SQL数据库创建。
Why not just use the model's constructor? 为什么不只使用模型的构造函数?
public class CustomerViewModel
{
public string Country { get; set; }
public CustomerViewModel()
{
this.Country = "Default value";
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.