Welcome Guest Search | Active Topics | Sign In | Register

Having Problem in DatePicker Options
Menon
Posted: Friday, November 2, 2007 2:22:06 AM
Rank: Advanced Member
Groups: Member

Joined: 8/9/2007
Posts: 59
Hi Friends,

I am using the DatePicker

<eo:DatePicker ID="txtDepTime" runat="server" SkinID="time" ></eo:DatePicker>

I want to use it as TimePicker . I able to take the Time from DataBase and display it in the DatePicker put i am not able to insert Time from the Picker back to the DataBase.

My Code where i takes Data From DB to the DatePicker
DatePickerDepTime.SelectedDate =TktLogEnt.DepartureTime;// Fetch Data From DB

My Code to Save it back in DB from DatePicker
TktLogEnt.DepartureTime = DatePickerDepTime.SelectedDate; // Store Data To DB from DatePicker

The Error:
The added or subtracted value results in an un-representable DateTime. Parameter name: value

The DepartureTime in my DB is of DataType DateTime.
And One cannot Enter only Time into this Column as it needs also Date.
That is the I need to Enter or it has to take the Date By Default.

Earlier i was using a normal TextBox From which i was easily able to Fetch and Store Records in this Column, and later i just gave a thought playing with the Datepicker i have and i saw it has for Time also.

Henceforth i am trying to use it as TimePicker also :) But i am stuck.

Any Help would be appreciated.

Thank you

Cheers

Menon
eo_support
Posted: Friday, November 2, 2007 6:09:49 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,083
Hi Menon,

As for the error message, please post the full stack trace. That will help us to identify where it occurs.

In order to use DatePicker to edit time value, you must set PickerFormat to include time elements, as detailed here:

http://www.essentialobjects.com/ViewDoc.aspx?t=EO.Web.DatePicker.PickerFormat.html

Thanks
Menon
Posted: Friday, November 2, 2007 7:03:44 AM
Rank: Advanced Member
Groups: Member

Joined: 8/9/2007
Posts: 59
Hi There,

I am using a third party tool called Adapdev Codus which Autogenerates and give me the Class files for DAO dataAccess Layer. I have never faced any problems with it. But my error is somewhere there for this DateTime

The added or subtracted value results in an un-representable DateTime.
Parameter name: value
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.ArgumentOutOfRangeException: The added or subtracted value results in an un-representable DateTime.
Parameter name: value

Source Error:


Line 600: parDepartureTime.ParameterName = "@DepartureTime";
Line 601: if(!entity.IsDepartureTimeNull)
Line 602: parDepartureTime.Value = entity.DepartureTime.Subtract(new TimeSpan(2,0,0,0)).ToOADate();
Line 603: else
Line 604: parDepartureTime.Value = System.DBNull.Value;


Source File: C:\TrueGreeceApp\TrueGreece.DataAccessObjects\DAO\Base\TicketLogDAOBase.cs Line: 602

Stack Trace:


[ArgumentOutOfRangeException: The added or subtracted value results in an un-representable DateTime.
Parameter name: value]
System.DateTime.Subtract(TimeSpan value) +2608833
TrueGreece.DataAccessObjects.TicketLogDAOBase.CreateUpdateCommand(Object o) in C:\TrueGreeceApp\TrueGreece.DataAccessObjects\DAO\Base\TicketLogDAOBase.cs:602
Adapdev.Data.AbstractDAO.Update(Object o) +35
TrueGreece.BusinessObjects.TicketLogBO.Update(TicketLogEntity forUpdate) in C:\TrueGreeceApp\TrueGreece.BusinessObjects\BusinessObjects\TicketLog.cs:36
Logs_TicketLogForm.btnSave_Click(Object sender, EventArgs e) in c:\Inetpub\wwwroot\TrueGreeceApp\Logs\TicketLogForm.aspx.cs:136


Thanks

Cheers
Menon
eo_support
Posted: Friday, November 2, 2007 7:16:34 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,083
Hi Menon,

Check the date part. When you use our DatePicker to input time, the date part is 1/1/0001 --- the mininum allowed date. So if you leave it empty, SelectedDate would be "1/1/0001". If you enter a time value, for example "1:00", it will be "1/1/0001 1:00".

If you try to subtract time from this value, you may get an error. For example, if the time user entered is "1/1/0001 1:00", and you try to subtract two days from it (new TimeSpan(2, 0, 0, 0, 0)), you will get that error because the minimum possible date is 1/1/0001, and you can not subtract two more days from it.

Mostly when you do not care about the date part, you are probably using today's date. So instead of doing:

DateTime userInput = DatePicker1.SelectedDate;

You might want to use:

DateTime userInput = DateTime.Today + DatePicker1.SelectedDate.TimeOfDay;

Thanks
Menon
Posted: Friday, November 2, 2007 7:36:12 AM
Rank: Advanced Member
Groups: Member

Joined: 8/9/2007
Posts: 59
Dear Admin

Thank you very much, I dont know how to say , but you really Helped me out.
Actully i didnt do
DateTime userInput = DateTime.Today + DatePicker1.SelectedDate.TimeOfDay;
But in my Entity Class i am initializing the Column DepartureTime. I initialized it as DateTime.Today;

And my problem was solved.

Thank you very much once again. EO objects has been the best choice , thats all i can Say :)

Cheers
Menon


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.