Date Format in GridViewDataColumn

1 posts, 0 answers
  1. raghul
    raghul avatar
    11 posts
    Member since:
    Jul 2010

    Posted 03 Jan 2012 Link to this post

    I have a date picker in the gridview and I need to format the date in that. I am able to do it perfectly. But the problem is that the format gets applied only when tab off takes place. The format which I have specified does not apply when I select the date.
    In order to achieve this I have done a work around as

     <telerik:GridViewDataColumn DataMemberBinding="{Binding Established}"
                                                DataFormatString="{}{0:M-dd-yyyy}" UniqueName="Unique1"

    private void pre_edit(object sender, GridViewPreparingCellForEditEventArgs e)
                if (e.EditingElement != null && e.EditingElement is Telerik.Windows.Controls.RadDatePicker)
                    if (e.Column.UniqueName.Equals("Unique1", StringComparison.InvariantCultureIgnoreCase))
                        RadDateTimePicker objRadDateTimePicker = e.EditingElement as Telerik.Windows.Controls.RadDatePicker;
                        objRadDateTimePicker.Culture = new CultureInfo("en-US")
                            DateTimeFormat = new DateTimeFormatInfo
                                ShortDatePattern = "M-dd-yyyy"

    Is there any other way of doing the same? Please help


Back to Top