问题描述:

My AppUser class contains following property

 public string UserName { get; set; }

public string Email { get; set; }

public Cities City { get; set; }

where Cities is an enum contains cities of AppUsers.

While i creating CRUD action methods for this user, i want to populate these cities as dropdownlist in my Views(I can convert enum to SelectList).

I tried to create a Viewmodel containing Cities enum as property, but for my edit action i am using direct AppUser as model. Here i can't populate them as Dropdownlist in Edit view.

In short, Without adding Cities to the user(viewmodel) class how can we pass SelectList to View. Tried Tempdata, Viewdata Viewbag but they disappear when app getting validation errors.

相关阅读:
Top