Page view counter

String was not recognized as a valid DateTime.

Last post 11-22-2007 11:55 PM by nthillaiarasu. 14 replies.

Sort Posts:

  • String was not recognized as a valid DateTime.

    04-29-2005, 10:42 AM
    • Loading...
    • mgshortt
    • Joined on 04-06-2004, 1:49 AM
    • Posts 25
    • Points 125

    Hi,

    Have just created a test website with the club starter kit.

    All looks good except when I try to view the events using Events_Calendar.aspx I get the error 'String was not recognized as a valid DateTime.'

    Any ideas what could be causing this?

    Thanks

    Mark

  • No [Nope] Re: String was not recognized as a valid DateTime.

    05-01-2005, 9:11 PM
    • Loading...
    • whup
    • Joined on 05-02-2005, 1:08 AM
    • Posts 2
    • Points 10
    I also get this error, and it's frustrating me.

    The error is occurring in EventCalendar.dll, which is a dll which ships with the solution in the bin folder. Yet there is no source code for this and I can't find it anywhere. Nor do I have access to a decompiler to decompile the code.

    Please MS can you include the EventCalendar project and source so we can diagnose and fix this problem.
  • Re: String was not recognized as a valid DateTime.

    05-01-2005, 9:16 PM
    • Loading...
    • whup
    • Joined on 05-02-2005, 1:08 AM
    • Posts 2
    • Points 10
    I tried decompiling this with the trial version of Spices.Net, but it cut out half of the methods (as it's the trial version).

    Error is occurring in the CreateDataBoundChildren method of EventCalendar, presumably on the line:

    dv.RowFilter = string.Format("{0}>= #{1}# AND {0} < #{2}#", DayField, dateTime1.ToString("MM/dd/yyyy"), dateTime2.ToString("MM/dd/yyyy"));

    Full stack trace:

    [FormatException: String was not recognized as a valid DateTime.]
    System.DateTimeParse.Parse(String s, DateTimeFormatInfo dtfi, DateTimeStyles styles) +2136542
    System.DateTime.Parse(String s, IFormatProvider provider) +26
    System.Data.ConstNode..ctor(DataTable table, ValueType type, Object constant, Boolean fParseQuotes) +544
    System.Data.ExpressionParser.Parse() +1168
    System.Data.DataExpression..ctor(DataTable table, String expression, Type type) +123
    System.Data.DataView.set_RowFilter(String value) +172
    ControlSample.EventCalendar.CreateDataBoundChildren(DataView dv, Table table, DateTime todaysDate, DateTime visibleDate, Calendar threadCalendar) +426
    ControlSample.EventCalendar.CreateChildControls(IEnumerable dataSource, Boolean dataBinding) +220
    System.Web.UI.WebControls.CompositeDataBoundControl.PerformDataBinding(IEnumerable data) +58
    System.Web.UI.WebControls.DataBoundControl.OnDataSourceViewSelectCallback(IEnumerable data) +114
    System.Web.UI.DataSourceView.Select(DataSourceSelectArguments arguments, DataSourceViewSelectCallback callback) +25
    System.Web.UI.WebControls.DataBoundControl.PerformSelect() +119
    System.Web.UI.WebControls.BaseDataBoundControl.DataBind() +68
    System.Web.UI.WebControls.BaseDataBoundControl.EnsureDataBound() +61
    System.Web.UI.WebControls.CompositeDataBoundControl.CreateChildControls() +67
    System.Web.UI.Control.EnsureChildControls() +103
    System.Web.UI.Control.PreRenderRecursiveInternal() +50
    System.Web.UI.Control.PreRenderRecursiveInternal() +171
    System.Web.UI.Control.PreRenderRecursiveInternal() +171
    System.Web.UI.Control.PreRenderRecursiveInternal() +171
    System.Web.UI.Control.PreRenderRecursiveInternal() +171
    System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +6326
  • Re: String was not recognized as a valid DateTime.

    05-08-2005, 5:15 PM
    • Loading...
    • Caddre
    • Joined on 06-23-2003, 9:53 AM
    • Indy
    • Posts 5,308
    • Points 26,551

    String is not recognized as Datetime because String is a reference type and Datetime is a value type and the .NET Calendar class is in INT and a few Double.  I have seen someone recommend Stringbuilder for value types but I have not used it.  Try the link below for the Calendar class.  Hope this helps.

    http://authors.aspalliance.com/aspxtreme/sys/globalization/calendarclass.aspx

    Kind regards,
    Gift Peddie
  • Re: String was not recognized as a valid DateTime.

    05-16-2005, 12:47 PM
    • Loading...
    • preishuber
    • Joined on 09-20-2002, 1:42 AM
    • Austria/Germany
    • Posts 206
    • Points 1,010

    i have not solved it, but i guess its a date format problem,

    i use a german OS which formats a dat like 30.12.2005

    US expect 12 / 30 / 2005

     

    -Hannes

    http://www.preishuber.net http://weblogs.asp.net/hpreishuber
  • Re: String was not recognized as a valid DateTime.

    05-16-2005, 12:52 PM
    • Loading...
    • preishuber
    • Joined on 09-20-2002, 1:42 AM
    • Austria/Germany
    • Posts 206
    • Points 1,010

    i have found a workaorund, not perfect but page is displayed

    explitly switch culture of this page to en-US

    <%@ Page Language="VB" MasterPageFile="~/Default.master" Title="Untitled Page" Trace="false" Culture="en-US" %>

    -Hannes

    http://www.preishuber.net http://weblogs.asp.net/hpreishuber
  • Re: String was not recognized as a valid DateTime.

    05-28-2005, 4:05 PM
    • Loading...
    • Caddre
    • Joined on 06-23-2003, 9:53 AM
    • Indy
    • Posts 5,308
    • Points 26,551
    The Asp.net team have posted complete code you can use.  Try the link below.  Hope this helps.

    http://forums.asp.net/938287/ShowPost.aspx
    Kind regards,
    Gift Peddie
  • Cool [cool] Re: String was not recognized as a valid DateTime.

    05-30-2005, 6:23 AM
    • Loading...
    • kia
    • Joined on 05-27-2005, 4:52 AM
    • Posts 7
    • Points 35

    Error indeed comes from Events_Calendar.dll.

    To solve the problem, I deleted this dll but included its source (CalendarDay.cs, DivCtrl.cs, EventCalendat.cs, ItemTemplates.cs) into the club project placed into App_Code directory. Debugger immedeatly indicated the source of the error. In EventCalandar.cs, line 256 I removed formatting "MM/dd/yy" from argument of d.ToString("MM/dd/yy").

    That's all.

  • Re: String was not recognized as a valid DateTime.

    09-17-2005, 4:52 PM
    • Loading...
    • jim-jambo
    • Joined on 09-17-2005, 8:46 PM
    • Posts 1
    • Points 5
    If anyone wants the recompiled eventscalender to work with uk dates mail me (nospam_james.clark@btinternet.com) remove the nospam_ 

    I might take a day to respond but will send.

    jim-jambo
  • Re: String was not recognized as a valid DateTime.

    09-19-2005, 6:46 AM
    • Loading...
    • MasterOz
    • Joined on 09-19-2005, 10:39 AM
    • Posts 2
    • Points 10

    Hello, I think I’ve found de solution for Localize EventCalendar.dll in Spanish (European) date format.

     

    Just change MM/dd/yyyy for dd/MM/ yyyy in the source code of EventCalendar.dll available in this forums… Anyway I am going to make the file public.

     

    Best Regards

     

  • Re: String was not recognized as a valid DateTime.

    12-02-2005, 3:42 AM
    • Loading...
    • stoefln
    • Joined on 11-28-2005, 2:48 PM
    • Posts 3
    • Points 15
    there has to be another way to switch from one language to the other for the WHOLE project, even for ALL projects on the webserver... had 2 projects running without any problems for about 2 years , but now, i think it has something to do with the .NET 1.1 update i have done, they have switched language and the result is 2 not workin webapps...

    any ideas!?

  • Re: String was not recognized as a valid DateTime.

    02-11-2007, 6:02 PM
    • Loading...
    • bryanevil
    • Joined on 01-07-2007, 10:53 AM
    • Posts 31
    • Points 7

    Hi, preishuber,

    the Culture="en-US" works on me. I am using at new zealand , and my test server at US, so i just add the line in my page and work fine on the server.

    cheers

  • Re: String was not recognized as a valid DateTime.

    02-14-2007, 10:54 PM

     

    In general I have found over the years that working with date and time has presented a varity of challenges. When converting from strings with asp.net I have found this simple example to provide reliable results...

    Dim sBirthDate As String = BirthDate.Text & ""
    If IsDate(sBirthDate) Then
        Dim dBirthDate As Date = Date.Parse(sBirthDate)
    Else
       
    Dim dBirthDate As Date = Date.Parse("1/1/1970") 'default
    End If

     

    Jerome C. Vernon
  • Re: String was not recognized as a valid DateTime.

    06-12-2007, 4:31 AM
    • Loading...
    • chriscee
    • Joined on 10-02-2006, 11:37 AM
    • Posts 59
    • Points 107

    Does anyone have this version of the dll or know where I can get the code for VS 2005?

  • Re: String was not recognized as a valid DateTime.

    11-22-2007, 11:55 PM
    • Loading...
    • nthillaiarasu
    • Joined on 07-02-2006, 12:34 PM
    • Bangalore
    • Posts 9
    • Points 6

    hi i too faced the same problem and i solved the problem.I just changed  System Globalization .

    For more details

     

     http://nthillaiarasu.blogspot.com/2007/11/string-was-not-recognized-as-valid.html

     

     

    N.ThillaiArasu
Page 1 of 1 (15 items)