2012-04-19 119 views
0

我试图用默认值填充editorfor字段。请帮助填充EditorFor字段

我的代码:

<div class="editor-label"> 
     @Html.LabelFor(model => model.Country) 
</div> 
<div class="editor-field"> 
     @Html.EditorFor(model => model.Country) 
</div> 

模型由throughmy SQL数据库实体框架创建。

+0

你能对你的问题更具体一些吗? – 2012-04-19 13:54:37

回答

3

为什么不使用模型的构造函数?

public class CustomerViewModel 
{ 
    public string Country { get; set; } 

    public CustomerViewModel() 
    { 
     this.Country = "Default value"; 
    } 
}