DataRow.IsNull 方法   
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
获取一个值,该值指示指定的列是否包含 null 值。
重载
| IsNull(DataColumn) | 获取一个值,该值指示指定的 DataColumn 是否包含 null 值。 | 
| IsNull(Int32) | 获取一个值,该值指示指定索引处的列是否包含 null 值。 | 
| IsNull(String) | 获取一个值,该值指示命名列是否包含 null 值。 | 
| IsNull(DataColumn, DataRowVersion) | 获取一个值,该值指示指定的 DataColumn 和 DataRowVersion 是否包含 null 值。 | 
IsNull(DataColumn)
- Source:
- DataRow.cs
- Source:
- DataRow.cs
- Source:
- DataRow.cs
获取一个值,该值指示指定的 DataColumn 是否包含 null 值。
public:
 bool IsNull(System::Data::DataColumn ^ column);public bool IsNull (System.Data.DataColumn column);member this.IsNull : System.Data.DataColumn -> boolPublic Function IsNull (column As DataColumn) As Boolean参数
- column
- DataColumn
返回
如果列包含 null 值,则为 true;否则,false。
例外
              column
              null。
该行不属于该表。
示例
以下示例打印 DataSet的每个表中每一行的每一列。 如果该行设置为 null 值,则不打印该值。
Private Sub PrintRows(dataSet As DataSet)
    Dim table As DataTable
    Dim column As DataColumn
    Dim row As DataRow
    For Each table In dataSet.Tables
       For Each row In table.Rows
          For Each column In table.Columns
             If Not row.IsNull(column) Then 
                Console.WriteLine(row(column).ToString())
             End If
          Next column
       Next row
     Next table
End Sub
适用于
IsNull(Int32)
- Source:
- DataRow.cs
- Source:
- DataRow.cs
- Source:
- DataRow.cs
获取一个值,该值指示指定索引处的列是否包含 null 值。
public:
 bool IsNull(int columnIndex);public bool IsNull (int columnIndex);member this.IsNull : int -> boolPublic Function IsNull (columnIndex As Integer) As Boolean参数
- columnIndex
- Int32
列的从零开始的索引。
返回
如果列包含 null 值,则为 true;否则,false。
例外
列与 columnIndex指定的索引不对应。
该行不属于该表。
示例
以下示例将列的值更改为 null 值,然后使用 IsNull 方法确定该值是否为 null。
Private Sub IsValNull()
    ' Assuming the DataGrid is bound to a DataTable.
    Dim table As DataTable = CType(DataGrid1.DataSource, DataTable)
    Dim row As DataRow = table.Rows(datagrid1.CurrentCell.RowNumber)
    row.BeginEdit
    row(1) = System.DBNull.Value
    row.EndEdit
    row.AcceptChanges
    Console.WriteLine(row.IsNull(1))
End Sub
适用于
IsNull(String)
- Source:
- DataRow.cs
- Source:
- DataRow.cs
- Source:
- DataRow.cs
获取一个值,该值指示命名列是否包含 null 值。
public:
 bool IsNull(System::String ^ columnName);public bool IsNull (string columnName);member this.IsNull : string -> boolPublic Function IsNull (columnName As String) As Boolean参数
- columnName
- String
列的名称。
返回
如果列包含 null 值,则为 true;否则,false。
例外
找不到由 columnName 指定的列。
              columnName
              null。
该行不属于该表。
示例
以下示例将列的值更改为 null 值,然后使用 IsNull 方法确定该值是否为 null。
 Private Sub IsValNull()
    ' Assuming the DataGrid is bound to a DataTable.
    Dim table As DataTable = CType(DataGrid1.DataSource, DataTable)
    Dim row As DataRow = table.Rows(datagrid1.CurrentCell.RowNumber)
    row.BeginEdit
    row("FirstName") = System.DBNull.Value
    row.EndEdit
    row.AcceptChanges
    Console.WriteLine(row.IsNull("FirstName"))
End Sub
适用于
IsNull(DataColumn, DataRowVersion)
- Source:
- DataRow.cs
- Source:
- DataRow.cs
- Source:
- DataRow.cs
获取一个值,该值指示指定的 DataColumn 和 DataRowVersion 是否包含 null 值。
public:
 bool IsNull(System::Data::DataColumn ^ column, System::Data::DataRowVersion version);public bool IsNull (System.Data.DataColumn column, System.Data.DataRowVersion version);member this.IsNull : System.Data.DataColumn * System.Data.DataRowVersion -> boolPublic Function IsNull (column As DataColumn, version As DataRowVersion) As Boolean参数
- column
- DataColumn
- version
- DataRowVersion
指定行版本的 DataRowVersion 值之一。 可能的值为 Default、Original、Current和 Proposed。
返回
如果列包含 null 值,则为 true;否则,false。
例外
              column
              null。
该行不属于该表。
该行没有请求的 version。