Click here to Skip to main content
15,908,444 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi friend
when i run my asp.net program then we have geting this massage (String was not recognized as a valid DateTime.) can solve this problem?
Posted
Comments
Timberbird 3-Jun-11 6:25am    
This kind of message can come from just almost anywhere :). Please clarify your question: provide us your page source code, Page_Load() handler code, at least anything. Or even better, put some breakpoints, trace your program, find out the line which is giving you exception... you're gonna need these skills in the future :)
Rob Branaghan 3-Jun-11 6:39am    
Check your Data Access Layer, and make sure that the datetime returned from your database isnt null or something.
(Just a guess)

In certain cases – including reading information from a database, quite often – you need to use DateTime.ParseExact. DateTime.Parse (used by default in data binding) will not accept some of the unambiguous formats (like YYYY-MM-DD HH:mm:ss which is typically used by databases).
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 3-Jun-11 23:21pm    
Correct, a 5. You could also advice to parse with culture parameter which support IFormatProvider.
--SA
There is a problem in converting a string to a Date.

Wherever you are converting a string to a date, make sure that the format of the date is proper.
 
Share this answer
 
Try adding following code under web.config <system.web>

<globalization culture="en-GB"/>
 
Share this answer
 
Make sure that u are using System.Globalization and also use generic date format e.g. "dd-MM-yyyy" in the complete application.
 
Share this answer
 
hi,


ya i had the same problem check the format of the string you trying to convert
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900