Thursday, April 4, 2013

Dynamic Data Entities Localization DateTime Field Template / DateTime_Edit



Had a problem with Localization for DateTime from a UTC set date, the solution was in the DateTime.ascx, and in the DateTime_Edit.ascx, I merely had to put an override for the FieldValue.

Of course, it's best practice to mark up your EF column with [DataType(DataType.DateTime)]

public override object FieldValue
        {
            get
            {
                return ((DateTime)base.FieldValue).ToLocalTime();
            }
            set
            {
                base.FieldValue = ((DateTime)value).ToUniversalTime();
            }
        }