Welcome Guest Search | Active Topics | Sign In | Register

date control only giving current date, even if selecting a different date Options
amillyard
Posted: Wednesday, January 23, 2008 5:06:24 PM
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.
eo_support
Posted: Wednesday, January 23, 2008 6:52:12 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,091
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
amillyard
Posted: Wednesday, January 23, 2008 7:52:50 PM
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.
eo_support
Posted: Wednesday, January 23, 2008 8:09:56 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,091
Cool! Thanks for the update!


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.