Welcome Guest Search | Active Topics | Sign In | Register

DatePicker Options
KathyH
Posted: Tuesday, May 21, 2013 11:36:03 AM
Rank: Newbie
Groups: Member

Joined: 5/21/2013
Posts: 3
I am in the process of testing the DatePicker to determine if I would like to purchase this feature. I am having the following issues. I hope you all can help me with this error message.

Here is some background, I am creating an ASP.NET website. I have added the DatePicker control to my DetailsView InsertItemTemplate on my form.

I have clicked on the Edit Calendar for the Datepicker and set the the datepicker attribute to PickerFormat="MM/dd/yyyy hh:mm:ss tt" I have it bound to the StartDate column in my SQL data table.

I have setup the Startdate column in my SQL table to be be datetime2(7) for the data type
I have setup the Insert Parameter to be <asp:Parameter DBType="DateTime2" Name="StartTime" />

I am getting the following error when I submit the data in my form:

Invalid cast from 'Boolean' to 'DateTime'.

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.InvalidCastException: Invalid cast from 'Boolean' to 'DateTime'.

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:


[InvalidCastException: Invalid cast from 'Boolean' to 'DateTime'.]
System.Boolean.System.IConvertible.ToDateTime(IFormatProvider provider) +134
System.Convert.ChangeType(Object value, TypeCode typeCode, IFormatProvider provider) +519
System.Web.UI.WebControls.Parameter.GetValue(Object value, String defaultValue, TypeCode type, Boolean convertEmptyStringToNull, Boolean ignoreNullableTypeChanges) +126
System.Web.UI.WebControls.Parameter.GetValue(Object value, String defaultValue, DbType dbType, Boolean convertEmptyStringToNull, Boolean ignoreNullableTypeChanges) +57
System.Web.UI.WebControls.Parameter.GetValue(Object value, Boolean ignoreNullableTypeChanges) +120
System.Web.UI.WebControls.SqlDataSourceView.AddParameters(DbCommand command, ParameterCollection reference, IDictionary parameters, IDictionary exclusionList, String oldValuesParameterFormatString) +550
System.Web.UI.WebControls.SqlDataSourceView.ExecuteInsert(IDictionary values) +306
System.Web.UI.DataSourceView.Insert(IDictionary values, DataSourceViewOperationCallback callback) +89
System.Web.UI.WebControls.DetailsView.HandleInsert(String commandArg, Boolean causesValidation) +379
System.Web.UI.WebControls.DetailsView.HandleEvent(EventArgs e, Boolean causesValidation, String validationGroup) +611
System.Web.UI.WebControls.DetailsView.OnBubbleEvent(Object source, EventArgs e) +95
System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +37
System.Web.UI.WebControls.DetailsViewRow.OnBubbleEvent(Object source, EventArgs e) +112
System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +37
System.Web.UI.WebControls.Button.OnCommand(CommandEventArgs e) +125
System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +167
System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +10
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +36
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +5563


eo_support
Posted: Tuesday, May 21, 2013 11:44:57 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,195
Hi,

I do not see where you actually associate the DatePicker to your asp:Parameter. I would imagine that unless you do that, you are not really getting any value from the DatePicker at all. For DatePicker, you can either bind to its SelectedDate property or SelectedDateString property. SelectedDate property is a value type so it does not support null value. SelectedDateString is of reference type so it supports null value.

Thanks!
KathyH
Posted: Tuesday, May 21, 2013 12:07:48 PM
Rank: Newbie
Groups: Member

Joined: 5/21/2013
Posts: 3
I looked in my code and between the <InsertParameters> tag I have this:
<asp:Parameter DbType="DateTime2" Name="StartTime" DefaultValue="" />

I tried to change it to this:
<asp:ControlParameter ControlID="StartTime" DefaultValue="" Name="DatePicker1" PropertyName="SelectedDate" />

but that made it worse, sorry to be so without clue.

eo_support
Posted: Tuesday, May 21, 2013 12:11:45 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,195
Hi,

I would suggest you to replace our DatePicker with a standard ASP.NET TextBox and get that working first. We know our controls, but we are not in a position to troubleshoot database problems for you. So you have to get that working first. Once you get that working, you can replace the TextBox with our DatePicker control and we can then continue from there.

Thanks!
KathyH
Posted: Wednesday, May 22, 2013 8:18:36 AM
Rank: Newbie
Groups: Member

Joined: 5/21/2013
Posts: 3
Based on the previous reply from you, I checked the Bindable Properties for the DatePicker and clicked on the Show All Properties check box and selected the "SelectedDates" and added my Custom Binding Bind("StartTime"). The datepicker worked perfectly.
eo_support
Posted: Wednesday, May 22, 2013 10:54:44 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,195
Great! Glad to hear that you got it working!


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.