Connecting Tech Pros Worldwide Help | Site Map

String was not recognized as a valid DateTime

 
LinkBack Thread Tools Search this Thread
  #1  
Old November 19th, 2005, 09:59 AM
Patrick Olurotimi Ige
Guest
 
Posts: n/a
Default String was not recognized as a valid DateTime

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, 09:59 AM
Patrick Olurotimi Ige
Guest
 
Posts: n/a
Default 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, 09:59 AM
Neverlyn
Guest
 
Posts: n/a
Default 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, 10:00 AM
Brock Allen
Guest
 
Posts: n/a
Default 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




 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 220,662 network members.