I have a ViewModel containing this property:
[Display(Name = "Email")]
[DataType(DataType.EmailAddress)]
[DisplayFormat(NullDisplayText = "Unavailable")]
public string Email { get; set; }
Is there a way to set the DataType
attribute dynamically to show it as a DataType.Text
if it's showing "Unavailable" (the NullDisplayText
), otherwise show it as a clickable DataType.EmailAddress
?
Now, when the property value is null, it shows like Unavailable while I want to show it as Unavailable.