What if I don't use foreach to get the row number that the cell value in which row

image
for example if I input 49, it would return 2 ,because it is in the second line

you can write select query and get index of that row by passing Value of particular column.

@jmy

Use the below query

int rownumber = yourDatatable.Rows.IndexOf((from x as datarow in yourDatatable where x(column index/coumn name).ToString.Equals(“your search value”) select x).First) +1

Replace the values in bold with your data. And your search value must be unique or else the query will return row number of the first occurrence.

Regards,
Ranjith

1 Like

Thank you very much
but I use the “for each row” dt.rows.Indexof(row) to get the row number

1 Like