Assign headerss

How to assign headers of my datatable as a variable

Hi,

If you need to get column name of the datatable as string array variable, the following will work.

arrColummnName = dt.Columns.Cast(Of DataColumn).Select(Function(dc) dc.ColumnName).ToArray()

If you need to set your string array variable as each column name to the datatable, the following helps you.

Regards,

error of “select is not a member of Enumerable of data column”

Hi,

Can you share information for your environment and language?

And also can you check the following sample?

Sample20221120-1aL.zip (4.8 KB)

Regards,

Hi,

I got your situation. Can you try the following expression?

dt.Columns.Cast(Of System.Data.DataColumn).Select(Function(dc) dc.ColumnName).ToArray()

Regards,

Main.xaml (22.0 KB)
its not working I want to put the headers into “claim type” check main to understand more so you can help me.

Hi,

Is your header dynamic?
Is so and you already know its index number, the following will work.

dt.Columns(0).ColumnName

The above return 0th column name.

Regards,

I have 11 columns so I want to take the 11nth headers. (all headers)

Hi,

If we need (0 based) n-th index Column name, the following works.

dt.Columns(n).ColumnName

I have 11 columns so I want to take the 11nth headers.

Can you try the following?

dt.Columns(10).ColumnName

And the following expression returns string array which has all the column name of the datatable.

dt.Columns.Cast(Of System.Data.DataColumn).Select(Function(dc) dc.ColumnName).ToArray()

Hope this helps you.

Regards,