When we obtain the data from the data, typically a DataTable received, then traverses each row of data. Since the data is read from the database may be empty, such as our compile the code as follows:
foreach (the DataRow the DataRow in the DataTable.Rows) { // If there is a name for the name, as if we need to determine is empty, how to write a column in the DataRow [ " name " ] }
Direct written as
datarow["name"] == null
Since datarow [ "name"] returns a target object, and this object is always empty, all such judgments never established.
After debugging can see datarow [ "name"] of type DBNull, DBNull represents the value does not exist
Whether it is possible to use the following judgment acquired data is empty:
if (datarow["name"] == DBNull.Value) {}