Current filter:
                                You should refresh the page.
                                Support Center
                                0
                                  • Hello, I have a dateEdit which I want the user to be able to 'Clear' the value. This should set the bound date (ExpiryDate) to be 1/1/1900 but I want the user to see nothing in the field. At the moment they are seeing 1/1/1900.
                                    How do I go about this? I have the following.

                                    <dxe:DateEdit Name="txtExpiryDate" EditValue="{Binding ExpiryDate}" DisplayFormatString="dd MMM yyyy" ShowNullText="True" NullText="" NullValue="1/1/1900" />

                                    Thanks in advance

                                0

                                Hi Phillip,

                                Thank you for contacting us. I believe that the cause of the issue is that the value you are passing to the NullValue property is considered as a string. That is why, a standard Object.Equals method returns false when NullValue is compared with EditValue. To solve the issue, you need to pass a DateTime value to the NullValue property. To do this, use a converter or assign this value programmatically.

                                If you need any further assistance with this subject, feel free to reactivate this ticket.

                                Thanks
                                Dimitros

                                0

                                Thanks for that,

                                I have updated my xaml to the following now that works. However when clicking on the field it shows 1/1/1900 (the NullValue). My question is can I suppress showing this at all or set it to empty?

                                                            <dxe:DateEdit Name="txtExpiryDate" EditValue="{Binding ExpiryDate}" DisplayFormatString="dd MMM yyyy" ShowNullText="True" NullText="" >
                                                                <dxe:DateEdit.NullValue>
                                                                    <sys:DateTime>1/1/1900</sys:DateTime>
                                                                </dxe:DateEdit.NullValue>
                                                            </dxe:DateEdit>

                                Thanks again,

                                0

                                Hi Phillip,

                                Thank you for the update. I suggest you use a Value Converter for this task in the following manner:

                                	
                                [C#]
                                public class Conv : IValueConverter { public DateTime Null { get; set; } public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { if(Null.Equals(value)) return null; return value; } public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { if(value == null) return Null; return value; } }

                                	
                                [XAML]
                                <local:Conv x:Key="conv"> <local:Conv.Null> <sys:DateTime>1/1/1900</sys:DateTime> </local:Conv.Null> </local:Conv> <dxe:DateEdit Name="txtExpiryDate" DisplayFormatString="dd MMM yyyy" ShowNullText="True" NullText="" EditValue="{Binding ExpiryDate, Converter={StaticResource conv}}"/>

                                Please try this solution and let me know of your results.

                                Thanks,
                                Alexander

                                0

                                Thanks that worked perfectly.

                                0

                                You are welcome, Phillip!

                                Thanks,
                                Alexander

                                To start a chat you should create a support ticket


                                If you need additional product information, write to us at info@devexpress.com or call us at +1 (818) 844-3383

                                FOLLOW US

                                DevExpress engineers feature-complete Presentation Controls, IDE Productivity Tools, Business Application Frameworks, and Reporting Systems for Visual Studio, along with high-performance HTML JS Mobile Frameworks for developers targeting iOS, Android and Windows Phone. Whether using WPF, Silverlight, ASP.NET, WinForms, HTML5 or Windows 8, DevExpress tools help you build and deliver your best in the shortest time possible.

                                Copyright © 1998-2014 Developer Express Inc.
                                All trademarks or registered trademarks are property of their respective owners