0

I am looking for some help on the syntax to check for DBNull inline in asp...

<EditItemTemplate>
  <asp:CheckBox ID="Checkbox1" runat="server" Checked='<%# If(isDBNull(Eval("activeType")).Value, False, Convert.ToBoolean(Eval("activeType"))) %>'></asp:CheckBox>
 </EditItemTemplate>

Hoping someone can show me the light on this one..

Thanks,

3
  • you can use ternay operator to accomplish the same. Commented Oct 15, 2012 at 18:28
  • could you provide an example? Commented Oct 15, 2012 at 18:30
  • The .Value seems incorrect, remove it and try again. Commented Oct 15, 2012 at 19:04

1 Answer 1

2

you had it fine , just take out .Value , isDBNull(Eval("activeType")) this will work , you can not get the Value of dbNull , so the exception is thrown before it actually gets to check if it's null

<EditItemTemplate>
<asp:CheckBox ID="Checkbox1" runat="server" Checked='<%# If(isDBNull(Eval("activeType")), False, Convert.ToBoolean(Eval("activeType"))) %>'></asp:CheckBox>
</EditItemTemplate>
Sign up to request clarification or add additional context in comments.

1 Comment

UPDATE is not posting the value back to the database. Correctly removes True, but also does not place False back in database.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.