Reputation: 1779
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,
Upvotes: 0
Views: 2052
Reputation: 9580
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>
Upvotes: 2