I have a user control like this
<uc1:wucSwitchButton3States runat="server" State="true" ID="wucSwitchButton3States" />
in the user control code behind I have declared a nullable property named state
public bool? State { get; set; }
if I set State as true of false it works fine but if I set it as null like this
<uc1:wucSwitchButton3States runat="server" State="null" ID="wucSwitchButton3States" />
I encounter with following error:
Cannot create an object of type 'System.Nullable`... from its string representation 'null' for the 'State' property.
I even tried State=""
and State="<%=null%>"
but none of them solved the issue, do you have any idea to resolve the problem?
based on the CheckBox Code, id did not try it myself but:
bool _state;
[TypeConverter(typeof(NullableBoolConverter))]
public bool? State
{
get { return _state; }
set { _state = value; RaisePropertyChanged(); }
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.