Aleksey, that does not work. When I tried specifically what you had I got an error:
error CS0019: Operator '==' cannot be applied to operands of type 'decimal' and 'System.DBNull'
If I changed it to:
Code: Select all
{Switch(MyDataSource.NumericColumn.Equals(DBNull.Value), string.Empty, MyDataSource.NumericColumn != null, MyDataSource.NumericColumn.ToString("N0") + " " + MyDataSource.UnitsColumn)}
I don't get an error, but when the database returns a NULL value it shows
0 feet rather than showing nothing.
Keep in mind that the column returned from the Data Source is configured as type
decimal. I tried changing the type to
string but for those it still reports that the string is NOT DBNull.Value, but rather an empty string.
It appears that when the Data Source is populated it uses the default value for the specified data type in the case that the column returned from the database is NULL. But I need to be able to determine in the report designer whether the value from the database happens to be the default value (0) or whether the value in the database is NULL. I can do some ugly hack, like in my query do an
ISNULL(Column, -99999) and then in the designer do a Switch on -99999, but I'm hoping there's something more graceful.
Thanks