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
419
datetime formatting
posted

I have few datetime columns in the grid which might have '01/01/0001' or "01/01/1900" values in them. To make sure they are not displayed i have added a check in the InitializeRow event handler and set the column values to Empty String.

I dont have control over the data source thats provided as of yet, but is there a better way of handling this in the grid ?

  • 69832
    Suggested Answer
    Offline posted

    An alternative approach would be to use the IEditorDataFilter interface, which is exposed via the editor's DataFilter property. The interface exposes a 'Convert' method, which you implement to convert values as they go back and forth from the editor to the column to the display, etc. In your case you would do something like handle the ConversionDirection of 'EditorToDisplay' or 'OwnerToEditor' (sorry, can't remember which) and return an empty string for the values that are considered "not really dates". With this approach, you would not be modifying the actual values but rather the way they are displayed.