I want to check a value inside a Datatable and if that value is found, I want to extract Column Name and value, where that particular value is located. I have used ‘IF’ Condition to check the value “CurrentRow.ItemArray.Contains(“0022218338”)” inside the iterative ‘For each row’ (for datatable) but don’t know how to pull the column name and the value when the value found.
Hi,
The following will return list of column index number which has the data of the row.
listInt32 = CurrentRow.ItemArray.Select(Function(x,i) if(x.ToString="0022218338",i,-1)).Where(Function(i) i>=0).ToList
And as you use Contains(“0022218338”), value will be just “0022218338”.
Regards,
The below expression would help
Currentrow("yourcolumnname/columnindex).ToString
Regards
Yes, Column Names are not fixed.
Problem is that I don’t know the column name as it is not fixed.
Hi,
The following returns list of column name which match the data.
listColumnNames = CurrentRow.ItemArray.Select(Function(x,i) if(x.ToString="0022218338",CurrentRow.Table.Columns(i).ColumnName,"")).Where(Function(s) not String.IsNullOrEmpty(s)).ToList
Regards,
Thanks. Let me try this.
It worked for me. Many thanks.
1 Like
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.