Click here to Skip to main content
15,886,963 members
Please Sign up or sign in to vote.
1.00/5 (3 votes)
See more:
I have a DatePicker control. I always get the error
Value '' cannot be converted


I set
TargetNullValue=''
. Not working

What I have tried:

I set <pre>TargetNullValue=''
. Not working
Posted
Updated 22-Feb-19 13:28pm
Comments
Richard MacCutchan 14-Feb-19 4:03am    
I would guess that you cannot convert a null value into whatever it is you are trying to convert it into. But since you have not shown the relevant code that is just a guess.

I added one more property then the error is gone.
C#
{FallbackValue='',TargetNullValue=''}
 
Share this answer
 
'' is not a value: it's a "character literal" without a character inside it. A bit like saying "a cup of coffee" without the cup!

You need a character specifier inside the quotes, like this perhaps which may insert a "null character" (not the same as a null value):
TargetNullValue = '\0'
 
Share this answer
 
Comments
Richard Deeming 14-Feb-19 9:59am    
The question is tagged "WPF", so I suspect this is in XAML. Since the TargetNullValue is usually set within an attribute, it tends to use single quotes to wrap the string - eg:
<TextBox Text="{Binding SomeProperty, TargetNullValue='No value set here...'}" />

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900