当我尝试编辑表单时,我的日期字段未显示。包括时间部分的每个字段都显示,但日期字段显示为默认格式。我检查了数据库表。日期字段的数据存储在那里,但是在编辑形式中它没有显示。
这是我的模特
namespace LeaveManagementSystem.Models
{
public class CompensatoryLeave
{
public int ID { get; set; }
[DataType(DataType.Date)]
[DisplayFormat(DataFormatString = "{0:dd-MMM-yyyy}", ApplyFormatInEditMode = false)]
public DateTime Date { get; set; }
[Display(Name = "Employee Name")]
public string Name { get; set; }
public Designation Designation { get; set; }
[Display(Name = "Compensatory Leave Hours")]
public decimal CompensatoryLeaveHours { get; set; }
[Display(Name = "Compensatory Leave Date")]
[DataType(DataType.Date)]
[DisplayFormat(DataFormatString = "{0:dd-MMM-yyyy}", ApplyFormatInEditMode = true)]
public DateTime CompensatoryLeaveDate { get; set; }
[Display(Name = "Starting Hour")]
[DataType(DataType.Time)]
[DisplayFormat(ApplyFormatInEditMode = true, DataFormatString = "{0:H:mm}")]
public DateTime From { get; set; }
[Display(Name = "Ending Hour")]
[DataType(DataType.Time)]
[DisplayFormat(ApplyFormatInEditMode = true, DataFormatString = "{0:H:mm}")]
public DateTime To { get; set; }
[Display(Name = "Total Compensatory Leave Hours")]
public decimal TotalHours { get; set; }
[Display(Name = "Reason Of Leave")]
public string ReasonOfLeave { get; set; }
}
}