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
Hi Rob,
If Nullable is true, then the control should allow you to blank out the Value property. The DateTime property cannot be null, because it's of type DateTime, which is a struct and does not support nulls.
Hi Mike,
I kept getting the error " value cannot be set outside the range of the min/max value . . ." something like that. I found the problem was comming from the fact that the application is using business object class, where a null datetime property will carry a value of "1/1/001 12:00:00 AM" which, if I am not mistaken, is different the Infragistics minimum value for this datatype,
Anyway, I corrected the problem by putting a check for Year on in the code that loads the data into form controls.
If myClass.RevisionDate.Date.Year = 1 Then
myDateControl.Value=Nothing
Else
myDateControl.Value= MyClass.RevisionDate
End If
I could have put the code in the Class property declaration itself, but then the class cause problems elsewhere accross the solution.
Regards,
The control does handle null dates by the way.
Your domain class would need to define the date as nullable "DateTime?" I also databind this just fine.
It's late but just FYI
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 :)
rlove@aecrepro.com
Just curious what your thoughts are for new nullable types.
Given the following is valid: DateTime? myDate = null;What can be done to allow this type of datavalue in the control/datasource?
I'm not sure exactly how this should function in the UltraDateTimeEditor, but I found this topic by searching around for information regarding UltraGrid and nullable types.
In my issue, I've got a grid with certain columns (with ValueLists) that need to be blank(null) before the user configures them, then also must be able to be defaulted back to the null state at the user's discretion .. I won't go into this anymore in this topic as i'm still looking around for more information before I ultimately post another topic/find a solution -- but you happened to touch on the nullable idea, and just thought you might have some clues. The main reason why i see the Nullable enum to be an issue, is that you can't explicitly define any type as the nullable type, and are restricted to a select few.
Hey Mike,
Ya know this is something that has been bugging me for ages. I am sure that it is quite common across many business process solutions, that there are requirements to have optional Date. For example, Project StartDate, ProjectEnd. A future date can always be entered into the StartDate if the process has yet to begin, but while the process is ongoing, we cannot have a value EndDate. Oddly enough, SQL Server has no problem handling this situation (ie passing null/nothing values to parameters with a Date data type).
This being the case, any Date Control aught to be able to handle whatever is considered to be a Null Date. In the .Net world, this value is 1/1/0001. Therefore, that portion of my Validation Layer that handles Date values, as well as the Data Access Layer that will pass such values to the database via ADO, have both been coded with respect to the Year 1 value. So everything is right, until I am compelled to use a date control on a front end. That’s the problem.
I think the Min/Max properties are right for Business Logic. preventing the user for entering a value that is outside a desired range. However, there must be some value that the control considers to be a Null Date, if not Year 1, then some other value assigned by the user. That would solve the problem quite nicely.
Regards,Rob
ps
It’s true, I could write the corrective code around the DataBinding Class, or in any of the Filters that you mentioned. However, I didn't want to write code every where, so doing it in the business class objects seemed the right thing to do. Do it there also corrected the display issue I was having with ultra grid columns that carried a grid column style of DateTime, which were also showing the Year 1 value instead of nothing.
I will post a link to this thread in a Feature Request
r.