Check first row of the table:if yes allow the whole dt through the loop

Hi, I would like to check if my first row of the dt contains ‘JAZ’, then allow the whole dt to loop thru in.

I tried this code. But it only lets the first row to loop through in as it contains the word.
dt1.Select(“Details like ‘JAZ’”).Length > 0

Any suggestions?
Thank you xoxo

You can also try this dt1.Rows(rowIndex)(colIndex).ToString

Use this to get the first row from your dataTable

dt1=dt1.AsEnumerable().Take(1).CopyToDataTable() then see if it Contains your string.

@PrankurJoshi not sure what you are trying to say. What should I enter as rowIndex and colIndex? and What will the outcome be?

dt.Rows(RowNumber)(ColNumber).ToString and you will get the value of that particular cell


As you said you would like to check the first row

1 Like

@nadim.warsi I tried your method. After it enters If condition, it gives invalid range error.

ok do one thing create a new DataTable dt2 from the above exppression for your if, but inside the if use the dt1

Hi @sangasangasanga,

If you want to check first row you can directly implement


If True the value is available in the first row

@nadim.warsi not working still :frowning:

what is the issue?

@PrankurJoshi @nadim.warsi @akila93
Hi, what you guys suggested, I tried them all. However, It is still not giving me the expected outcome.

after you tried this what was the result?

HI @sangasangasanga,

Please refer this xaml file

DataTableRow.xaml (7.6 KB)

For More related to datatable refer below link