|
Rank: Member Groups: Member
Joined: 11/18/2007 Posts: 18
|
Hi there,
Using the date control.
On aspx page -- have the date control and x2 drop down menu's for selecting the hour and minutes.
What I wanting to achieve is get all 3 values into the single 'smalldatetime' format.
The hour and minutes are working fine...just that the date is always today's -- even if I select a different date on the page -- it always get displayed in the database as the current date.
Below is the c# server-side script that I use to perform the merge.
int hour = Convert.ToInt32(DropDownList_ManualHour.Text); int minute = Convert.ToInt32(DropDownList_ManualMinutes.Text);
DateTime dateOnly = DatePicker_ProspectCallBack.SelectedDate; // date control, aspx page DateTime dateTime = new DateTime(dateOnly.Year, dateOnly.Month, dateOnly.Day, hour, minute, 0);
Hopefully you can discover where I am going please?
Thank you in advance for your time and efforts with this enquiry.
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,217
|
Hi,
Your code looks perfectly fine. So the problem must lie somewhere else. I would recommend you to try starting from a blank page and then adding code into it step by step and see where the problem occurs. (Of course, always try to update the latest version first).
Thanks
|
|
Rank: Member Groups: Member
Joined: 11/18/2007 Posts: 18
|
Thank you for your speedy response and confirming your understanding of the supplied -- this provided confidence in that part of trying to find the solution.
Wanted to afford you the respect of a follow-up response.
What I discovered in the end, was that the serverDateTime retrieval was place outside these brackets -- which meant that anytime and update on the page was performed, the date was automatically being reset etc with the current date. moved this code inside those brackets and works perfectly.
if (!Page.IsPostBack) { [should sit here] }
Again, many thanks for your time and efforts with checking script earlier.
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,217
|
Cool! Thanks for the update!
|
|