Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Setting default value of DateTimePicker

Currently my DateTimePickers are blank, I would like them to have a default setting i.e

Today.AddYears(20); & Today.AddDays(5);

What I have done at the moment is 'DateTimePicker.Text = DateTime.Today.AddYears(-100).ToString();' As you can probably tell, this isn't working hence why I'm asking the question.

Bit of information :- I need it so that if they arent changed and the button is pressed it uses the default dates. If they are changed, I obviously need to use the changed dates.

Suggestions.

XAML ADDED:

<igEditors:XamDateTimeEditor Name="startDateTimePicker"
  Grid.Row="1"
  Grid.Column="1"
  xmlns:igEditors="http://infragistics.com/Editors"
  Height="18"
  Width="100"
  Format="yyyy-MM-dd"
  VerticalAlignment="Top"
  HorizontalAlignment="Center" />
like image 830
Vibralux Avatar asked Aug 17 '10 10:08

Vibralux


People also ask

How do I change the default value of a DatePicker?

It Seems simple. $('#startdatetime-from'). datetimepicker({ language: 'en', format: 'yyyy-MM-dd hh:mm' });


1 Answers

Setting the Value property should do the trick:

DateTimePicker.Value = DateTime.Today.AddYears(-100);

And since it's type is DateTime, you don't need any ToString conversions.

like image 114
Oded Avatar answered Oct 18 '22 14:10

Oded