You can quote rows and columns by checking for zeros, keeping track of whether there is a zero with bool, and then checking it after scrolling through the table and process it.
//your DataTable, replace with table get code DataTable table = new DataTable(); bool tableHasNull = false; foreach (DataRow row in table.Rows) { foreach (DataColumn col in table.Columns) { //test for null here if (row[col] == DBNull.Value) { tableHasNull = true; } } } if (tableHasNull) { //handle null in table }
You can also exit the foreach loop with a break statement, for example.
//test for null here if (row[col] == DBNull.Value) { tableHasNull = true; break; }
To save the loop in the rest of the table.
StuperUser Jan 05 2018-11-11T00: 00Z
source share