How to find Empty Columns of datatable


#1

I want to check a single row of datatable having empty fields.
Suppose In 1st row want to check to which columns are empty by name.
How can I Do that.


#2

Hi @amarjeet_kumar,

In my example, when a specific column header doesn’t contain a name, it basically comes with ‘Column’ and a number in its name, for example, in my excel file the empty column header was renamed to ‘Column1’ in the datatable. Kindly check the attached example.

example.zip (7.8 KB)


#3

I do not believe that the previous answer is correct.

In my example I have looped through each of the data columns in the table using DataColumn as the object. You are then able to reference the column name. You will see that any blank column headers are automatically entitled “Column1” and would increment accordingly e.g. Column2, Column3 - you could then use these columns to rename or delete as required.

Here is a link to the online solution and the xaml file and test.csv document are attached.

http://stackoverflow.com/questions/6791894/in-vb-net-how-to-get-the-column-names-from-a-datatable

Checking Empty Columns.zip (1.8 KB)

Richard