Last post Mar 01, 2012 10:12 AM by Qi Wu - MSFT
Feb 24, 2012 01:13 AM|anilr499|LINK
i have datofbirth column ....
through a date picker am giving the input...
if i give > 12 for dd....
if i give 13/4/2012
it is not taking....
it is not accepting the value....
in my database format is yyyy/mm/dd
Can some body help me....
Feb 24, 2012 01:16 AM|Ken Tucker|LINK
it probably wants 13/04/2012
Feb 24, 2012 01:25 AM|anilr499|LINK
if igive this also 13/04/2012....
Mar 01, 2012 10:12 AM|Qi Wu - MSFT|LINK
Your problem is caused by the default culture information. You can define a custom culture and assign it to the current thread. You can do it in the Application_BeginRequest event. The all the request will use the new culture. You can refer to the below
code. You should remember to add the System.Gobalization namespace. The Application_BeginRequest() method is in the Global.asax.cs file.
protected void Application_BeginRequest(object sender, EventArgs e)
CultureInfo myCulture = System.Threading.Thread.CurrentThread.CurrentCulture.Clone() as CultureInfo;
myCulture.DateTimeFormat.ShortDatePattern = "dd/MMM/yyyy";
myCulture.DateTimeFormat.DateSeparator = "/";
System.Threading.Thread.CurrentThread.CurrentCulture = myCulture;
You can’t get your answer with the above code. You need to change it again in the code behind.
DateTime dt = new DateTime();
dt = DateTime.Parse(TextBox1.Text);