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
nadim.warsi
(Nadim Warsi)
3
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.
nadim.warsi
(Nadim Warsi)
7
ok do one thing create a new DataTable dt2 from the above exppression for your if, but inside the if use the dt1
akila93
8
Hi @sangasangasanga,
If you want to check first row you can directly implement
Convert.ToString(dt.Rows(0)("Details")).ToUpper.Contains("JAZ")
If True the value is available in the first row
@nadim.warsi not working still 
@PrankurJoshi @nadim.warsi @akila93
Hi, what you guys suggested, I tried them all. However, It is still not giving me the expected outcome.
nadim.warsi
(Nadim Warsi)
13
after you tried this what was the result?
akila93
14
HI @sangasangasanga,
dt.Rows(0).ItemArray.Contains("JAZ")
Please refer this xaml file
DataTableRow.xaml (7.6 KB)
For More related to datatable refer below link
2 Likes