문제

I need to get selected date from calendar and show it in textbox in format dd/MM/yyyy. I have this code, but it does not work.

datum_odevzdani.Text = (calendar_odevzdani.SelectedDate.ToString("dd/MM/yyyy"));
도움이 되었습니까?

해결책

The type of the Calendar.SelectedDate property is Nullable<DateTime>. Hence you have to access the contained DateTime by the Nullable<T>.Value property:

if (calendar_odevzdani.SelectedDate.HasValue)
{
    datum_odevzdani.Text = calendar_odevzdani.SelectedDate.Value.ToString("dd/MM/yyyy");
}
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top