Click here to Skip to main content
15,884,298 members
Please Sign up or sign in to vote.
4.09/5 (3 votes)
Hello To All,

I am working with one web application inside that i have One Date-time picker. when i have change Culture of Application English to Gujarati Date-time picker format also change in Gujarati and in database i have date-time with date format,

But when i try to stored that date into Gujarati it throw me conversion error.

I try with changing culture with English to Gujarati but still it's not work..

How i can do this Please help me..



Thanks & Regards
Posted
Updated 7-Aug-14 0:18am
v3

1 solution

1.There are two property of the current thread that control the current culture:
- Thread.CurrentThread.CurrentUICulture - control the UI part
- Thread.CurrentThread.CurrentCulture - control the logic part, including the conversion of DateTime to the culture needed by the SQL server.

2.In your code, before to convert the data (DateTime, but also numerical values) that come from the UI you should convert it to DateTime value you should use the 2nd current culture property, supposing that you are set it to be the culture info needed by your logic (and your SQL server), like in the example bellow:
C#
DateTime myDate;
DateTime.TryParse(dateStringFromUI, System.Threading.Thread.CurrentThread.CurrentCulture, DateTimeStyles.AllowWhiteSpaces, out myDate)
 
Share this answer
 
Comments
Jay1902 7-Aug-14 6:39am    
If i do this on .cs file , And one more thing if i want to only change the culture of datetime picker not whole application , than what i have to do.

Thanks for Reple
Raul Iloc 7-Aug-14 7:01am    
1.Yes, the changes must be in the .cs file.
2.You should replace the Thread property with your CultureInfo object like the next one:
new CultureInfo("gu-IN")

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