Question

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

No correct solution

OTHER TIPS

I am going to take a stab

Checked='<%# BindItem.databaseValue ?? false %>'

I think this works with Item (AKA Eval) anyway. CheckBox is weird.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top