473,326 Members | 2,081 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

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 ***
Nov 19 '05 #1
3 30601
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 ***
Nov 19 '05 #2
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:
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 ***

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


Why don't you just do this instead:

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

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


Nov 19 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Sterling Ledet | last post by:
I am trying to create a web service that takes a string from my web server in the following format: Mon, 6 Oct 2003 18:39:47 UTC and put's in a datetime so it can then be reformatted in C# as...
1
by: adolf garlic | last post by:
I'm having a problem with dates. (No not the sort that you have at christmas) I have a webform with a text box and a calendar control. You can either - enter a date manually (we are talking uk...
0
by: RSH | last post by:
I am having a bit of trouble filling a datatable with a query. I'm getting the error message: System.FormatException: String was not recognized as a valid DateTime. at...
6
by: Rookie Card | last post by:
I know this is a very common issue but cannot find a thread that resolves the issue. I need to re-format my dates to "MMM d, yyyy". The problem I have is I have an MSSQL database that allows...
1
by: database | last post by:
I AM FACING A PROBLEM WHEN I ACCESS ONE OF THE PAGES. IT USED TO WORK BEFORE BUT AFTER RESTARTING THE APPLICATION SEVER IT GIVES THE FOLLOWING ERROR. - Server Error ...
1
by: Scott Holman | last post by:
I'm connecting to a java web service that defines the following complex type in the wsdl <xs:complexType name="employee"> <xs:sequence> <xs:element minOccurs="0" name="firstName"...
10
by: mercea | last post by:
hi all, i'm trying to insert the time/date a button was clicked on a gridview and it generates an error:the string was not recognized as a valid DateTime.There is an unknown word starting at index 0...
0
by: Andres Bohren | last post by:
Hi i have a GridView and have Problems to put the values into the right Datatypes. Protected Sub GridView1_RowUpdating(ByVal sender As Object, ByVal e As...
4
by: dhanashivam | last post by:
hi, in my web application i am getting date values from sql server database and store in the datatable. it works fine when i use the US culture. But when i change the culture to british i am...
3
by: lucindaa | last post by:
Hi, i have a string variable having date as following format "05-01-2010" when convert this date into DateTime Format i got the following error 'String was not recognized as a valid DateTime'...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.