0

hi,
i m facing problem whil making a submission form.
i want to update the value of datetimepicker when a value in month's passed to it by the help of textbox.
suppose dtpicker showing a date
07/07/2010
when i pass the value 20(in month), it will update the value in datetimepicker in hi.cs form.

2
Contributors
1
Reply
3
Views
7 Years
Discussion Span
Last Post by finito
0

when i pass the value 20(in month), it will update the value in datetimepicker in hi.cs form.

?

how can you have month = 20?

Well anyway I think I know what you want to do.

You want to pass the day to the Datetime picker.

Well there are a couple of ways I think this is the best one for your case.

Here is an example of setting the Date in DateTime Picker in yyyy-mm-dd format

dateTimePicker1.Value = new DateTime(2009, 8, 15);

What you want would be something like this

dateTimePicker1.Value = new DateTime(dateTimePicker1.Value.Year, dateTimePicker1.Value.Month, 20);

What this means is Get the current Year and month selected in the datetime picker but pass 20 as the day.

You can pass the month or year in a similar fashion


On the other hand if what you want to do is add 20 months to the current selection.

What you do is

dateTimePicker1.Value.AddMonths(20);

Please Mark as solved if solved.

Enjoy

Edited by finito: n/a

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.