Re: Checkbox = null, Specified cast is not valid.

Tech-Archive recommends: Fix windows errors by optimizing your registry



On Oct 25, 10:58 pm, rkbnair <rkbn...@xxxxxxxxxxxxxxxx> wrote:
<edititemtemplate>
<asp:CheckBox ID="giChkBox_bln_removed" runat="server" Checked='<%#
Bind("bln_removed")%>'></asp:CheckBox>
</edititemtemplate>

The above line gives an error (Specified cast is not valid.) if the field
bln_removed is null. Without changing the SQL select statement how can we fix
this?

In C#:

<%# Bind("bln_removed")==DBNull.Value ? "" : Bind("bln_removed") %>

In VB.NET:

<%# IIf(IsDBNull(Bind("bln_removed")), "", Bind("bln_removed")) %>

.