Best way to check if a Data Table has a null value in it

前端 未结 6 1248
感情败类
感情败类 2020-11-27 02:34

what is the best way to check if a Data Table has a null value in it ?

Most of the time in our scenario, one column will have all null values.

(This datatabl

6条回答
  •  孤城傲影
    2020-11-27 03:21

    DataTable dt = new DataTable();
    foreach (DataRow dr in dt.Rows)
    {
        if (dr["Column_Name"] == DBNull.Value)
        {
            //Do something
        }
        else
        {
            //Do something
        }
    }
    

提交回复
热议问题