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
305
UltraDateTimeEditor Nullable Property
posted

What is the purpose of the Nullable property.  Regardless if it is set to True, the MinDate Property cannot be Null or Nothing and the DateTime Property cannot be Null or Nothing.  So, how do you get the control to display nothing when the data field is Nullable and the current record has a Null value.

regards,

Rob

Parents Reply Children
  • 220
    posted in reply to Rob

     Rob,

     Thanks for your response -- i believe i've come to a suitable solution -- i've overviewed this  here .

    I know exactly what you mean about using the grid as an editor -- sometimes it just becomes a huge mess. However, with the requirements for the project i'm doing, a grid is required, and really the best choice. Furthermore, simply re-binding a modified datasource would create an annoying user experience in my case.

    That being said, The solution I've come across does deal with the null values better. Conveniently, .NET does support nullable types (using the '?' at the end of the type declaration). However, using these nullable types causes an issue in some of hte underlying codebase of the Infragistics control, i believe -- at least as it pertains to DropDownListValidated styles on the ValueLists inside a grid. (i get exceptions when the grid is trying to compare a value to make sure it is 'valid'). You can see my 'temporary' solution in the post I linked above.

    What was specifically happening to me was that inside the cell which was associated with a ValueList, A value could be selected from the list, but it was then impossible to clear the value. The first item in the list was always a null instance of my nullable enum, but even selecting the item from the list would not work, and would yield 'the data in the field is not valid' popup. If the user pressed Delete while in the field, the grid poped up a JIT Debugger error window, which was caused by the internal DropDownListValidate behavior.

    Also, just to clarify, DBNull does not translate to Nothing (C# null)  ;-) and this, i think, was the basis of my issue. 

    Back to the issue of the null value in the DateTimeEditor ... i would expect that if your datasource for the control was a property described as:
             DateTime? myDateTime = null;
    the control would be able to deal with this, and instead of using System.DBNull as a default null type, use either a configured null type (in the UltraGrid this is the Nullable property, which gives a few options), or be able to specify your own specific null value. 

    This way, you can avoid having to deal with the minimum date, and simply go with something like if (myDateTime.HasValue) { } else { }. One thing, however, is how does the user set the date back to 'null', to which I don not know the answer.

     

    Hope that helps :)