After the
I am a net code that receives a set of data / records in a GridView and renders it to the user. Some columns of dates are included when I export this data in Axle, the user's regional settings will be set to UK, the datetime format remains fine for the column. However, when computers with US regional settings are exported, columns in Excel format and 'DD' are left in Excel column equal to more than 12 because it is month for US settings. In essence, I want to check for the first time and then want to change the format according to different user's area settings. I'v was scratching my head with culture but with no production do any appreciate on this help? Here's what I'm trying to do:
Enter the code here
protected zero gvReportHidden_OnRowDataBound (Object Sender, GridViewRowEventArgs e) {CultureInfo CurrentCulture = CultureInfo. CurrentCulture;
if (currentCulture.NativeName.Equals ("N-UK")) {e.Row.Cells [8] .text = DateTime.Parse (e.Row.Cells [8]. Text) .ToString ("dd / mm / yyyy"); E. Ro Seals [9]. Text = date time Purse (e.ro. seals [9]. Text). Ostring ("DD / MM / yay"); } Else {e.Row.Cells [8] .text = DateTime.Parse (e.Row.Cells [8] .text) .ToString ("MM / dd / yyyy"); E.Row.Cells [9] .text = DateTime.Parse (e.Row.Cells [9] .text) ("MM / dd / yyyy") .toString; }}
You probably have to explicitly set the time when you output the culture variable . Here is an example from MSDN:
using the system; Using System.Globalization; Using System.Threading; Public Class Test Class {Public Fixed Zero Main () {Thread.CurrentThread.CurrentCulture = new CultureInfo ("en-US"); Date time DT = Date time.Now; Console.lightline ("today is {0}", date time.Now string ("D")); // increase DT till one day. Dt = dt.AddDays (1); Console.lightline ("tomorrow is {0}", dt. tostring ("d")); }} // If you execute this code on August 3, 2001, it displays the following output: Today 8/3/2001 tomorrow 8/4/2001
and one List of Quick Google Search available culture changes:
The list is too long so I did not post it, but you should be able to easily find the UK culture code < / P>
Comments
Post a Comment