I am going to take a stab
Checked='<%# BindItem.databaseValue ?? false %>'
I think this works with Item (AKA Eval) anyway. CheckBox is weird.
题
Im leveraging model binding in my ASP.Net WebForms application, facing problem while binding nullable bit to checkbox, in my aspx page i have something like
<li>IS A ChkBox</li>
<li>
<asp:CheckBox ID="someid" runat="server"
MaxLength="100" Checked='<%# BindItem.databaseValue%>'>
</asp:CheckBox>
</li>
initially when the form is populated the value is null and i get a NullReferenceException
, Object reference not set to an instance of an object.
, how can i get around this.
Regards
没有正确的解决方案
其他提示
I am going to take a stab
Checked='<%# BindItem.databaseValue ?? false %>'
I think this works with Item (AKA Eval) anyway. CheckBox is weird.