Export (0) Print
Expand All
1 out of 10 rated this helpful - Rate this topic

How to: Handle Null Values in a DataColumn 

In a typed dataset, you can control the representation of columns that contain null values. This behavior is only available when retrieving column values through their typed accessors. If you retrieve the value by means of the table's row index or column index, you will not be able to set the return value. The reason for this is that the logic to return this value is built into the property setter of the specific data column in the generated dataset class.

To set the value to return when a DataColumn's value is null

  1. Open the dataset in the Dataset Designer.

  2. Select a column in a data table.

  3. In the Properties window, select the NullValue property.

  4. Do one of the following:

    • From the drop-down list, select the appropriate value:

      Value Description

      (Empty)

      Returns null values System.String.Empty.

      (Nothing)

      Returns null values as DBNull.

      (Throw exception)

      Null values throw an Exception.

      -or-

    • Set the property to any custom value valid for that column's data type. For example, if you specify the string No Value, for a column with a data type of String, any records that contain null values in that column will display "No Value".

See Also

Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.