DateTime formats in GridView based on Cultural settings
-
Hello friends, I set the cultural info for Germany as CultureInfo ci = new CultureInfo("de-DE"); // format is dd.MM.yyyy Then I bound the GridView, but the date field shows data in system's local date format( eg m/d/yyyy). How to get the date field to be displayed according to the cultural format Please help me Regards
Shivanandan C V
-
Hello friends, I set the cultural info for Germany as CultureInfo ci = new CultureInfo("de-DE"); // format is dd.MM.yyyy Then I bound the GridView, but the date field shows data in system's local date format( eg m/d/yyyy). How to get the date field to be displayed according to the cultural format Please help me Regards
Shivanandan C V
I suspect you'd have to either ask the client their locale, get a database to map IP addresses to locales, or do something in javascript. Most sites ask the user where they are and store that info.
Christian Graus Driven to the arms of OSX by Vista.
-
Hello friends, I set the cultural info for Germany as CultureInfo ci = new CultureInfo("de-DE"); // format is dd.MM.yyyy Then I bound the GridView, but the date field shows data in system's local date format( eg m/d/yyyy). How to get the date field to be displayed according to the cultural format Please help me Regards
Shivanandan C V
Shivan Nandan wrote:
How to get the date field to be displayed according to the cultural format
CultureInfo ci = new CultureInfo("de-DE");
DateTime.Now.ToString(ci.DateTimeFormat.ShortDatePattern, ci.DateTimeFormat)But this will not help you as you are using ASP.NET. This will use servers culture information. As Christian told, you need to have some mechanism to get the users culture. Most easy way is to ask them to provide it.
Navaneeth How to use google | Ask smart questions
-
Shivan Nandan wrote:
How to get the date field to be displayed according to the cultural format
CultureInfo ci = new CultureInfo("de-DE");
DateTime.Now.ToString(ci.DateTimeFormat.ShortDatePattern, ci.DateTimeFormat)But this will not help you as you are using ASP.NET. This will use servers culture information. As Christian told, you need to have some mechanism to get the users culture. Most easy way is to ask them to provide it.
Navaneeth How to use google | Ask smart questions
Dear friend, Thanks for your response. I am not using dt.tostring() method. My code is given below DataSet ds = new DataSet(); ds = obj.GetData(); gvList.DataSource = ds; gvList.DataBind(); The "ds" contains records and one of the field will be a datetime type. So I want that datetime field value to be displayed according to the cultural settings. Also gvList's Autogenerate colums is true.
Shivanandan C V