|Important||This document may not represent best practices for current development, links to downloads and other resources may no longer be valid. Current recommended version can be found here. ArchiveDisclaimer|
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
Open the dataset in the Dataset Designer.
Select a column in a data table.
In the Properties window, select the NullValue property.
Do one of the following:
From the drop-down list, select the appropriate value:
Returns null values.
Returns null values as.
Null values throw an.
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, any records that contain null values in that column will display "No Value".