2012-04-19 120 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"; 
    } 
}