抱歉,如果这个问题已经有答案,但我找不到。
提交表单时,我的ViewModel会丢失一些值。具体来说,错误对象会丢失其值。我不明白为什么。我没有任何东西可以覆盖它。我非常感谢我能得到的任何帮助。
我尝试删除= new ...(),但这会使程序抛出错误
不是对象的实例
视图模型:
namespace Vacation.ViewModels
{
public class EditScheduleViewModel : BaseViewModel
{
public EditScheduleError Error { get; set; } = new EditScheduleError();
public string GotoSched { get; set; } = "";
public string GotoURL { get; set; } = "";
public string Title { get; set; } = "";
public bool isLast { get; set; } = false;
public User Employee { get; set; } = new User();
public int TotalWeeks { get; set; } = 2;
public Schedule ScheduleActive { get; set; } = new Schedule();
public DateTime LastSchedEndDate { get; set; }
public List<Schedule> ScheduleAll { get; set; } = new List<Schedule>();
public List<ScheduleDay> Days { get; set; } = new List<ScheduleDay>(new ScheduleDay[28]);
public List<int> ClinicIds { get; set; } = new List<int>(new int[28]);
public List<ClinicInfo> ClinicsList { get; set; } = new List<ClinicInfo>();
public EditScheduleViewModel ()
{
ProjectName = "Scheman";
}
}
public class EditScheduleError
{
public bool Overlaps { get; set; }
public EditScheduleOverlappingError OverlappingError { get; set; } = new EditScheduleOverlappingError();
}
public class EditScheduleOverlappingError
{
public bool OverlapsBefore { get; set; }
public bool OverlapsAfter { get; set; }
public int IdBefore { get; set; }
public int IdAfter { get; set; }
public EditScheduleOverlappingErrorResolutions Resolution { get; set; } = new EditScheduleOverlappingErrorResolutions();
}
public class EditScheduleOverlappingErrorResolutions
{
public bool ChangeThis { get; set; }
public bool ChangeOther { get; set; }
}
}
这不是控制器的全部部分...您需要更多吗?
预期的行为是错误保持其值,即使在我提交了表单之后也是如此。
holdtom
相关分类