Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
380
WebDateChooser is hyjacking my date format
posted

I have a databound grid.  One of the columns is a date in yy/MM/dd.  The date is in the correct format coming from the select statement.

Here is what the date should look like:

08/12/04

A straight bind of this field to the grid it displays fine. 

I embed a Web WebDateChooser to the column and this go awry.  Here's the embed code (in event InitializeLayout):

            e.Layout.Bands[1].Columns.FromKey("due_dt").DataType = "System.DateTime";
            e.Layout.Bands[1].Columns.FromKey("due_dt").Type = ColumnType.Custom;
            e.Layout.Bands[1].Columns.FromKey("due_dt").EditorControlID = IbsWebDatePicker1.UniqueID;

 

Now my column displays the date as: 08/12/2004

The values have not changd order, but the column thinks my day is the year and slaps the year prefix on it.

I try changing the date formats (both long and short) to match my resultset of yy/MM/dd with the following code:

            System.Globalization.CultureInfo info = new System.Globalization.CultureInfo("en-US");
            info.DateTimeFormat.ShortDatePattern = "yy/MM/dd";
            info.DateTimeFormat.LongDatePattern = "yy/MM/dd";
            info.DateTimeFormat.DateSeparator = myFormat.fieldSeparator;
            this.CalendarLayout.Culture = info;

 

Now my date displays as: 04/08/12

It has completely restructured my date.

Anyone have any idea what's going on and how to fix it???  I don't have any of these issues when using WebDateChooser outside of a grid.

 

  • 2254
    posted

    Hello,

    Try to set the culture for the entire web form (on the Page_Init() or Page_Load() event):

    System.Threading.Thread.CurrentThread.CurrentCulture =info;