Q:

Display ViewModel value with @Html.DropDownListFor

Let's say my database has a reference table that maps the values Zebra, Goat, and Dog onto the keys 0, 1, and 2, and a DropDownList where a user can select one of these values.
@Html.DropDownListFor(
    m => m.Animal,
    new SelectList(
        new List<Object>{
            new {value = 0, text = "Zebra"},
            new {value = 1, text = "Goat"},
            new {value = 2, text = "Dog"}
        },
        "value",
        "text"
    ),
    new { @class = "form-control" }
)

After the user's selection is saved to the database, I'm trying to figure out a way to display the value for m => m.Animal.  It's saved as a 2, but I want the displayed text to read Dog.  How do I set the default selected value on the @Html.DropFownListFor equal to the user's selection (e.g. 2), so the selected item displays the text Dog?

A:

I'm seeing two possible meanings to your question, so I guess I'll just cover them both.
If you're talking about making the drop down show the proper selected value, Razor should take care of this for you. However, the fact that you're defining the actual SelectList object, without specifying the selectedValue param, may be getting in the way. Technically DropDownListFor only needs IEnumerable<SelectListItem>, not an actual SelectList, and it's usually better to pass it the former as it's both easier and less prone to error:
@Html.DropDownListFor(
    m => m.Animal,
    new List<SelectListItem> {
       new SelectListItem { Value = "0", Text = "Zebra" },
       new SelectListItem { Value = "1", Text = "Goat" },
       new SelectListItem { Value = "2", Text = "Dog" }
    },
    new { @class = "form-control" }
)

If, however, you're talking about how to translate the value 2 into Dog at some later point in your code, then you should actually employ something like an enum. For example:
public enum Animals
{
    Zebra = 0,
    Goat = 1,
    Dog = 2
}

Then, change your Animal property to be of this type:
public Animals Animal { get; set; }

Finally, and since you're running MVC5, you can just use:
@Html.EnumDropDownListFor(m => m.Animal, new { @class = "form-control" })

You don't even need to pass a list of options because the helper will just get them from the enum the Animal property is typed to.
Then, when you want to display the selected animal type, you just use:
@Html.DisplayFor(m => m.Animal)

And Dog or whatever it's set to will be output automatically.

