2008-07-10

check for DbNull

Check for DbNull:
<_a s p :Label runat="server" ID="Label6" Text='< % # IIF(Typeof(
Eval("ShippedDate")) IS DbNull,"No Date",Eval("ShippedDate")) % >' />
or
<_%# ((Convert.IsDBNull ... I am telling ASP to give the picture a height value only if the value in the database is not NULL. I could've done this in the SQL instruction, but I decided to do it inside the Datalist.
<_%# ((Convert.IsDBNull(DataBinder.Eval(Container.DataI tem, "height"))) ? "" : "height = " + DataBinder.Eval(Container.DataItem, "height")) %> 
Or maybe this for NULLs?: <_%# Eval("First", "{0}, ") %_>
Or check for NULL in T-SQL:
ISNULL(check_expression, replacement_value) If 1st is NULL, return 2cnd.
Post a Comment