Abhilash JA Abhilash JA - 1 year ago 94
C# Question

error - Linq query returns true or false if Null value in the row

The DataTable 'IsActive1' field return empty value.

enter image description here

I have written Linq query,

enter image description here

But, It occured error. How can I solve this?

Answer Source

Write the definition of the column as bool? if you expect to be null.

myRow.Field<bool?>("IsActive1") == null ? true: myRow.Field<bool?>("Active1") ...
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download