i have datatable first row headers need specific column datatable according header
i know how column if know index. problem how index
dim columnindex integer dim headerrow datarow = dt.rows(0) dim colheader string ="abc" columnindex=??? dim result = dt.rows.cast(of datarow)().[select](function(row) row(columnindex)).distinct().tolist()
thanks
you may use dt.rows.indexof
dim valuetosearch string = ... columnindex = dt.asenumerable().where(function(x) x.field(of string)(colheader) = valuetosearch).select(function(x) dt.rows.indexof(x)).singleordefault()
the above work if clause returns 1 or 0 rows. if not true may dismiss singleordefault , loop through results, ie:
columnindex = dt.asenumerable().where(function(x) x.field(of string)(colheader) = valuetosearch).select(function(x) dt.rows.indexof(x)) each in columnindex console.writeline("value found in row index " + i.tostring()) next
giannis
Comments
Post a Comment