Condition Syntax for Finding a Value in a Row Within an Extracted DT?

What is the condition syntax for finding a value within an extracted DT without specifying the column that it might be in?

DT = CourseCodeDT
Row # I want to look at = rowCount
Variable I want to find = CourseCode

I want to set the condition if CourseCode does exist in rowCount of CourseCodeDT

1 Like

Try this

CourseCodeDT.Rows(rowCount).ItemArray.Contains(CourseCode)

2 Likes

That condition did not give me validation errors :slight_smile:

When I have it log the rowCount of the DT, it equals 14. However, when I run an IF activity on the rowCount, it says that there is no row at position 14.

Any ideas as to why this could be occurring?

image

CourseCodeDT.Select(" ColumnName = ‘“+CourseCode+”’ ")

It will return Array of DataRows

The index of the first row is 0, so if you have 14 rows the last row is at position 13.

Hey @stephanie

if you do not know the columns Headers and you want to find if any cell value CourseCode exist in any rows columns?

you can use this query as well:

DataColumn columns = Extracted_Datatable.Columns.Cast(Of DataRow).ToArray;

bool anyFieldContainsCourseCode = Extracted_Datatable.AsEnumerable().Any(function(row) columns.Any(function(col) row(col).ToString() == “CourseCode”));

Regards…!!
Aksh

Hi @aksh1yadav

I have a datable, now i used for each loop to get each row of the datatable.
Im not able to get cell value of the each row.
could you please help me.
Datable name : Generatedatatable
foreach item in Generatedatatable.Rows
item.value → something like this is not working. :frowning:

Thanks&regards,
Hemanth.

In you item you have a DataRow, you need to specify which column you want the value from.

For example, first cell is item(0), or if you have column headers item(“Header1”).

br,
Topi