I am learning ASP.Net MVC 5 and I want to set default value using data annotation for boolean property. Also I don't want to use the constructor to set the default value. Is it possible?
public class BalanceDetailMV
{
public BalanceDetailMV()
{
this.isUnitNoEmptyInAllRow = true; // I do not want this
}
public bool isUnitNoEmptyInAllRow { get; set; }
}
My attmept:
[DefaultValue("true")]
public bool isUnitNoEmptyInAllRow { get; set; }
But above does not work. Please guide me.