I have a viewmodel that has an int StateID
field and a string StateName
field like so:
public class DepartmentViewModel : BaseViewModel, IModelWithId
{
// only show in edit mode
public int StateId { get; set; }
// only show in display mode
public string StateName { get; set; }
}
I have a read only view that uses DisplayForModel
and an update view that uses EditorForModel
. I want the DisplayForModel
view to show the StateName
property, and the EditorForModel
view use the StateID
property (I am actually rendering a dropdownlist based on this).
I have not been able to figure out how to decorate my viewmodel properties to create this behavior.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…