Connecting Tech Pros Worldwide Help | Site Map

String was not recognized as a valid DateTime

  #1  
Old November 19th, 2005, 10:59 AM
Patrick Olurotimi Ige
Guest
 
Posts: n/a
I moved some projects to another server and using the code below i get
the error:-

"String was not recognized as a valid DateTime"

<asp:Label runat="server" width="40%" text='
<%#
DateTime.Parse(DataBinder.Eval(Container,"DataItem .dt").ToString()).ToSh
ortDateString()%>' id="Label6">


*** Sent via Developersdex http://www.developersdex.com ***
  #2  
Old November 19th, 2005, 10:59 AM
Patrick Olurotimi Ige
Guest
 
Posts: n/a

re: String was not recognized as a valid DateTime


Well folks...
I added:-
culture="en-US"
to the globalization in Web.Config and did the trick

<globalization
requestEncoding="utf-8"
responseEncoding="utf-8"
culture="en-US"
/>



*** Sent via Developersdex http://www.developersdex.com ***
  #3  
Old November 19th, 2005, 10:59 AM
Neverlyn
Guest
 
Posts: n/a

re: String was not recognized as a valid DateTime


Hi Patrick,

If you just use DataBinder.Eval(Container,"DataItem.dt").ToString( ) is
anything displayed?

If it is, I would be checking that the date format matches your Regional
Settings (System Account). If you are using SQL I’d also be checking that
the collation of the new server/database is the same as your old one.

Brad.


"Patrick Olurotimi Ige" wrote:
[color=blue]
> I moved some projects to another server and using the code below i get
> the error:-
>
> "String was not recognized as a valid DateTime"
>
> <asp:Label runat="server" width="40%" text='
> <%#
> DateTime.Parse(DataBinder.Eval(Container,"DataItem .dt").ToString()).ToSh
> ortDateString()%>' id="Label6">
>
>
> *** Sent via Developersdex http://www.developersdex.com ***
>[/color]
  #4  
Old November 19th, 2005, 11:00 AM
Brock Allen
Guest
 
Posts: n/a

re: String was not recognized as a valid DateTime


> <asp:Label runat="server" width="40%" text='[color=blue]
> <%#
> DateTime.Parse(DataBinder.Eval(Container,"DataItem .dt").ToString()).To
> Sh
> ortDateString()%>' id="Label6">[/color]

Why don't you just do this instead:

<%# ((DateTime)DataBinder.Eval(Container.DataItem, "dt")).ToShortDateString()
%>

-Brock
DevelopMentor
http://staff.develop.com/ballen




Closed Thread


Similar Threads
Thread Thread Starter Forum Replies Last Post
String was not recognized as a valid DateTime Andres Bohren answers 0 February 12th, 2008 07:25 PM
error:the string was not recognized as a valid DateTime. mercea answers 10 August 30th, 2007 01:43 PM
Error: String was not recognized as a valid DateTime database answers 1 January 9th, 2007 12:35 PM
System.FormatException: String was not recognized as a valid DateTime RSH answers 0 November 19th, 2005 01:35 PM