문제

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top