I have CalendarCombo and the user can DropDown and select the date my Question is : how we can prevent user to clear calender(make it none) because I am using the following code in CalendarCombo1_AfterCloseUp event and it's give me input string error :
DateTime enterDate = DateTime.Parse(CalendarCombo_From.Value.ToString()); DateTime todayDate = DateTime.Parse(CalendarCombo_To.Value.ToString());
int val_end = DateTime.Compare(todayDate, DateTime.Now); if (val_end != 1)//if Date To bigger than today date { int val = DateTime.Compare(enterDate, todayDate); if (val == 1)//if Date From bigger than Date To { CalendarCombo_From.Value = DateTime.Now; } } else { CalendarCombo_To.Value = DateTime.Now; }
I'm not certain that I followed this but you can set AllowNull to false to prevent the Value property from being nullified.
I was not able to reproduce the problem you describe here with a simple test. You should report the issue and include a test project that demonstrates the behavior so we can investigate further.