When I call the calendar module, I'm getting the following error in day and week view:
String was not recognized as a valid DateTime.
I'm getting the following error when I click the month view:
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.FormatException: String was not recognized as a valid DateTime.Source Error: Line 103: DateTime dtDAY_END = dtDAY_START.AddDays(1); Line 104: // 09/27/2005 Paul. System.Data.DataColumn.Expression documentation has description how to define dates and strings. Line 105: vwMain.RowFilter = " DATE_START >= #" + dtDAY_START.ToString() + "# and DATE_START < #" + dtDAY_END.ToString() + "#" + ControlChars.CrLf Line 106: + "or DATE_END >= #" + dtDAY_START.ToString() + "# and DATE_END <= #" + dtDAY_END.ToString() + "#" + ControlChars.CrLf Line 107: + "or DATE_START < #" + dtDAY_START.ToString() + "# and DATE_END > #" + dtDAY_END.ToString() + "#" + ControlChars.CrLf;Source File: C:\Inetpub\wwwroot\SplendidCRM\Calendar\MonthView.ascx.cs Line: 105 Stack Trace: [FormatException: String was not recognized as a valid DateTime.] System.DateTimeParse.GetDayOfNNY(DateTimeResult result, DateTimeRawInfo raw, DateTimeFormatInfo dtfi) +202 System.DateTimeParse.ProcessTerminaltState(Int32 dps, DateTimeResult result, DateTimeRawInfo raw, DateTimeFormatInfo dtfi) +142 System.DateTimeParse.Parse(String s, DateTimeFormatInfo dtfi, DateTimeStyles styles) +488 System.DateTime.Parse(String s, IFormatProvider provider, DateTimeStyles styles) +30 System.DateTime.Parse(String s, IFormatProvider provider) +11 System.Data.ConstNode..ctor(ValueType type, Object constant, Boolean fParseQuotes) +891 System.Data.ExpressionParser.Parse() +870 System.Data.DataExpression..ctor(String expression, DataTable table, Type type) +149 System.Data.DataView.set_RowFilter(String value) +151 SplendidCRM.Calendar.MonthView.ctlCalendar_DayRender(Object source, DayRenderEventArgs e) in C:\Inetpub\wwwroot\SplendidCRM\Calendar\MonthView.ascx.cs:105 System.Web.UI.WebControls.Calendar.OnDayRender(TableCell cell, CalendarDay day) +143 System.Web.UI.WebControls.Calendar.RenderDays(HtmlTextWriter writer, DateTime firstDay, DateTime visibleDate, CalendarSelectionMode selectionMode, Boolean buttonsActive) +1366 System.Web.UI.WebControls.Calendar.Render(HtmlTextWriter writer) +960 System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +243 ASP.MonthView_ascx.__Render__control1(HtmlTextWriter __output, Control parameterContainer) +200 System.Web.UI.Control.RenderChildren(HtmlTextWriter writer) +27 System.Web.UI.Control.Render(HtmlTextWriter writer) +7 System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +243 System.Web.UI.Control.RenderChildren(HtmlTextWriter writer) +72 System.Web.UI.HtmlControls.HtmlForm.RenderChildren(HtmlTextWriter writer) +44 System.Web.UI.HtmlControls.HtmlForm.Render(HtmlTextWriter output) +262 System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +243 _ASP.Month_aspx.__Render__control1(HtmlTextWriter __output, Control parameterContainer) +152 System.Web.UI.Control.RenderChildren(HtmlTextWriter writer) +27 System.Web.UI.Control.Render(HtmlTextWriter writer) +7 System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +243 System.Web.UI.Page.ProcessRequestMain() +1926
Line 103: DateTime dtDAY_END = dtDAY_START.AddDays(1); Line 104: // 09/27/2005 Paul. System.Data.DataColumn.Expression documentation has description how to define dates and strings. Line 105: vwMain.RowFilter = " DATE_START >= #" + dtDAY_START.ToString() + "# and DATE_START < #" + dtDAY_END.ToString() + "#" + ControlChars.CrLf Line 106: + "or DATE_END >= #" + dtDAY_START.ToString() + "# and DATE_END <= #" + dtDAY_END.ToString() + "#" + ControlChars.CrLf Line 107: + "or DATE_START < #" + dtDAY_START.ToString() + "# and DATE_END > #" + dtDAY_END.ToString() + "#" + ControlChars.CrLf;
[FormatException: String was not recognized as a valid DateTime.] System.DateTimeParse.GetDayOfNNY(DateTimeResult result, DateTimeRawInfo raw, DateTimeFormatInfo dtfi) +202 System.DateTimeParse.ProcessTerminaltState(Int32 dps, DateTimeResult result, DateTimeRawInfo raw, DateTimeFormatInfo dtfi) +142 System.DateTimeParse.Parse(String s, DateTimeFormatInfo dtfi, DateTimeStyles styles) +488 System.DateTime.Parse(String s, IFormatProvider provider, DateTimeStyles styles) +30 System.DateTime.Parse(String s, IFormatProvider provider) +11 System.Data.ConstNode..ctor(ValueType type, Object constant, Boolean fParseQuotes) +891 System.Data.ExpressionParser.Parse() +870 System.Data.DataExpression..ctor(String expression, DataTable table, Type type) +149 System.Data.DataView.set_RowFilter(String value) +151 SplendidCRM.Calendar.MonthView.ctlCalendar_DayRender(Object source, DayRenderEventArgs e) in C:\Inetpub\wwwroot\SplendidCRM\Calendar\MonthView.ascx.cs:105 System.Web.UI.WebControls.Calendar.OnDayRender(TableCell cell, CalendarDay day) +143 System.Web.UI.WebControls.Calendar.RenderDays(HtmlTextWriter writer, DateTime firstDay, DateTime visibleDate, CalendarSelectionMode selectionMode, Boolean buttonsActive) +1366 System.Web.UI.WebControls.Calendar.Render(HtmlTextWriter writer) +960 System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +243 ASP.MonthView_ascx.__Render__control1(HtmlTextWriter __output, Control parameterContainer) +200 System.Web.UI.Control.RenderChildren(HtmlTextWriter writer) +27 System.Web.UI.Control.Render(HtmlTextWriter writer) +7 System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +243 System.Web.UI.Control.RenderChildren(HtmlTextWriter writer) +72 System.Web.UI.HtmlControls.HtmlForm.RenderChildren(HtmlTextWriter writer) +44 System.Web.UI.HtmlControls.HtmlForm.Render(HtmlTextWriter output) +262 System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +243 _ASP.Month_aspx.__Render__control1(HtmlTextWriter __output, Control parameterContainer) +152 System.Web.UI.Control.RenderChildren(HtmlTextWriter writer) +27 System.Web.UI.Control.Render(HtmlTextWriter writer) +7 System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +243 System.Web.UI.Page.ProcessRequestMain() +1926
Version Information: Microsoft .NET Framework Version:1.1.4322.2300; ASP.NET Version:1.1.4322.2300
The problem is that .ToString() is not converting the date to a format that DataView.RowFilter understands. This is actually a common problem with date handling that is typically solved by using Parameter objects instead of string concatenation. However, since RowFilter does not support Paramters, we must code the concatenation in a format understood by all cultures. The trick is to specify the format as Year/Month/Day,
ToString("yyyy/MM/dd HH:mm:ss")
The following files needed to be fixed:
DayGrid.ascx.csMonthView.ascx.csSharedGrid.ascx.csWeekGrid.ascx.cs
We will have to research this issue more. What can you tell me about the languages of the Microsoft products? Are you running the English or Italian version of Windows?
My system is in English, Paul.
Alberto