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.

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.