I am trying to make the ID
field read only. It is an Identity field in the DB so the user will not be setting it. However they would like to see it. What am I missing as the below, when assigned to a DataForm
still allows that value to be Edited.
public class StatusChoice : BindableBase
{
private int id;
[Key, DatabaseGenerated(DatabaseGeneratedOption.Identity)]
[Editable(false,AllowInitialValue = false)]
public int ID
{
get { return id; }
set
{
id = value;
OnPropertyChanged();
}
}
}
Mark Property with ReadOnly attribute.
[ReadOnly(true)]
public decimal BodyMassIndex { get; private set; }
Follow below link for more Has the behavior for DataAnnotations in asp.net mvc 3 changed?