Msmit1993
Msmit1993

Reputation: 1710

Fill EditorFor Field

I'm trying to fill a editorfor field with a default value. 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.

Upvotes: 0

Views: 225

Answers (1)

John H
John H

Reputation: 14655

Why not just use the model's constructor?

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

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

Upvotes: 3

Related Questions