I am running into some oddness with CultureInfo and the asp.net datagrid.
Basically, I have an http handler that wires up to the httpapplication.BeginRequest event. HEre is the code:
HttpApplication applicaiton = (HttpApplication)sender;
HttpContext context = applicaiton.Context;
if (context != null)
{
// set the culture info for later processing
Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture(context.Request.UserLanguages[0]);
Thread.CurrentThread.CurrentUICulture = new CultureInfo(context.Request.UserLanguages[0]);
}
I also moved the last 2 lines of code into the web user control giving me the problem. Basically in the web user control, I fetch an entity collection from the sql database (which stores the data in a culture invariant way) and I bind the collection to the asp.net grid.
For some cells the dates look right, and for some they dont. It seems like the second date cell in each row is wrong, i.e. showing the US date when it should be displaying whatever the browsers setting is. I am setting the data format string for each data column that is a date to
{0:d}
which is the short date format and should use the current threads culture.
Has anyone experienced anything like this? I get the same results on servers in both AU and the US.