C# 字段的填充编辑器
我正在尝试用默认值填充editorfor字段。请帮忙 我的代码:C# 字段的填充编辑器,c#,.net,asp.net-mvc,html-helper,editorfor,C#,.net,Asp.net Mvc,Html Helper,Editorfor,我正在尝试用默认值填充editorfor字段。请帮忙 我的代码: <div class="editor-label"> @Html.LabelFor(model => model.Country) </div> <div class="editor-field"> @Html.EditorFor(model => model.Country) </div> @LabelFor(model=>model
<div class="editor-label">
@Html.LabelFor(model => model.Country)
</div>
<div class="editor-field">
@Html.EditorFor(model => model.Country)
</div>
@LabelFor(model=>model.Country)
@EditorFor(model=>model.Country)
模型是由实体框架通过我的SQL数据库创建的。为什么不使用模型的构造函数呢
public class CustomerViewModel
{
public string Country { get; set; }
public CustomerViewModel()
{
this.Country = "Default value";
}
}
为什么不直接使用模型的构造函数呢
public class CustomerViewModel
{
public string Country { get; set; }
public CustomerViewModel()
{
this.Country = "Default value";
}
}
你的问题能再具体一点吗?你的问题能再具体一点吗?