I have the following code -
Label1..Text = dt.AsEnumerable().Sum(x => x.Field<decimal?>("col1") ?? 0).ToString("#,#.####", CultureInfo.InvariantCulture);
here, I show the sum of 'col1' on the label.
I check x.Field<decimal?>("col1")for null values
the problem is that if the column value is 1234, it displays correctly, but if x.Field<decimal?>("col1")it is null, it takes the value ZERO and nothing is displayed on the label.
It seems that toString ignores the value if it is zero and returns nothing.
Please, help
source
share