haansi
haansi

Reputation: 5730

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

Upvotes: 27

Views: 114266

Answers (2)

James McG
James McG

Reputation: 1031

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

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

Upvotes: 103

Thit Lwin Oo
Thit Lwin Oo

Reputation: 3438

For one column

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

For more than one column

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

Upvotes: 7

Related Questions