Вопрос

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