How to Use Datatable. Select() to Select Null/ Empty Values?

My data table filled from db is having empty values in some cells.

The results database SP return has Null in them but in DataTable these values are appearing as '' or empty cells.

Please guide me how to use Select() to select these dbnull/ empty rows.

Thanks

2

2 Answers

The correct way to check for null is to check for it:

DataRow[] myResultSet = myDataTable.Select("[COLUMN NAME] is null");
6

For one column

DataRow rows = DataTable.Select("[COLUMN 1]=''");

For more than one column

DataRow rows = DataTable.Select("[COLUMN 1]='' OR [COLUMN 2]=''");
4

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

James H. Sterling

James H. Sterling

Environmental Science & Climate Journalist

James Sterling reports on renewable energy developments, climate policy, ecological conservation, and green tech innovations around the globe.

Share this article
Twitter Facebook Pinterest