GridViewDateTimeColumn handling null values

2 posts, 0 answers
  1. scottw
    scottw avatar
    23 posts
    Member since:
    Oct 2010

    Posted 06 Aug 2013 Link to this post

    I have a GridView with a  GridViewDateTimeColumn, and I have managed to figure out how to display no text in the editor when the cell value is null, however I need to also allow the user the  option of setting the value to null if a value exists.

    When the pop up editor appears, i cannot see a way to customize the popup or the text editor to allow this to happen.

            private void gvLibrary_CellEditorInitialized(object sender, GridViewCellEventArgs e)
                GridTimePickerEditor editor = e.ActiveEditor as GridTimePickerEditor;
                if (editor != null)
                    RadTimePickerElement editorElement = editor.EditorElement as RadTimePickerElement;
                    editorElement.Format = "HH:mm:ss";
                    editorElement.NullText = "";
                    editorElement.NullValue = 0;
                    if (e.Value != null)
                        editorElement.Value = e.Value; 
                        ((TextBox)(editorElement.MaskedEditBox.TextBoxItem.TextBoxControl)).Text = "";

    Can you provide me with the necessary elements to allow the user to delete values in the text box or from the pop-up and a way to ensure that the editor's null value is passed to the grid cell?

    Thank you,


  2. George
    George avatar
    500 posts

    Posted 09 Aug 2013 Link to this post

    Hi Scott,

    Thank you for writing.

    We kindly ask you to use just one support channel to contact us. Posting the same questions numerous times slows down our response time because we will need to review and address two or more tickets/forum posts instead of one. Moreover threads are handled according to license and time of posting, so if it is an urgent problem, we suggest you use a support ticket, which would be handled before a forum thread. However I am copying my answer here as someone may find it helpful. 

    I am copying my answer here as well, so the community can benefit from it:

    You can clear the editor by calling the SetToNullValue method of the RadDateTimeEditorElement. For example it can be done when the user presses the Delete Key. Please take a look at the code below:
    void grid_CellEditorInitialized(object sender, GridViewCellEventArgs e)
         RadDateTimeEditor editor = e.ActiveEditor as RadDateTimeEditor;
         if (editor != null)
             RadDateTimeEditorElement editorElement = editor.EditorElement as RadDateTimeEditorElement;
             editorElement.KeyUp -= editorElement_KeyDown;
             editorElement.KeyUp += editorElement_KeyDown;
             editorElement.NullText = "";
     void editorElement_KeyDown(object sender, KeyEventArgs e)
         if (e.KeyCode == Keys.Delete)
             (sender as RadDateTimeEditorElement).SetToNullValue();

    Thank you for your understanding.
    Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
    Sign up for Free application insights >>
Back to Top