Get number of columns, each column name from a DataRow

Hi @DEATHFISH,

If you have a datarow object then you can use itemarray method

datarowobject.itemarray.count.tostring

The above expression will give number of values in that row, the same number represents the number of columns also.

For extracting column names you can use the below linq query

Refer the below linq query to extract column names from datatable

(From dc In dt.Columns.Cast(Of DataColumn)
Select dc.ColumnName).ToArray()

Refer the post for more reference.

1 Like