DataGridViewCellStyle.DataSourceNullValue Property

Note: This property is new in the .NET Framework version 2.0.

Gets or sets the value saved to the data source when the user enters a null value into a cell.

Namespace: System.Windows.Forms
Assembly: System.Windows.Forms (in

public Object DataSourceNullValue { get; set; }
/** @property */
public Object get_DataSourceNullValue ()

/** @property */
public void set_DataSourceNullValue (Object value)

public function get DataSourceNullValue () : Object

public function set DataSourceNullValue (value : Object)

Property Value

The value saved to the data source when the user specifies a null cell value. The default is DBNull.Value.

The user can enter a null value into a cell by pressing CTRL+0 or by typing the value of the NullValue property. When the user commits the change, the underlying cell value is set to the value of the DataSourceNullValue property or to a null reference (Nothing in Visual Basic) if DataSourceNullValue is DBNull.Value and the cell ValueType is a reference type. This conversion does not occur when you set the DataGridViewCell.Value property programmatically.


The control does not display the NullValue property value for cell values equal to the DataSourceNullValue property value when DataSourceNullValue is set to a value other than DBNull.Value or a null reference (Nothing in Visual Basic). In this case, you can handle the DataGridView.CellFormatting event to display the NullValue property value.

Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.

.NET Framework

Supported in: 2.0

Community Additions