I'm using below code to remove empty columns from datatable before it's databind to datagridview. When I run the sql query, I have 14135 rows and also steping thru the code it shows 14135 for defaultview.rowfilter when I get thru below code once, but once it hits next and goes thru it the second time to check the second column, it changes the defaultview.rowfilter to 858. Why does it do that, because it only shows 858 rows on datagrid and I need it to show 14135?
Dim Col As DataColumn
For i As Integer = dTable.Columns.Count - 1 to 0 step -1
Col = dTable.Columns(i)
If col.DataType Is GetType("String") Then
dTable.DefaultView.RowFilter = Col.ColumnName & "<>''"
If dTable.DefaultView.Count = 0 Then
dTable.Columns.Remove(col)
End If
End If
Next