c# datagridview – Find a row in DataGridView by specific cell value

Updated on     Kisan Patel


Find a row in dataGridView based on column and value
Datagridview full row selection but get single cell value
Ho do I get the cell value from a datagridview using row index and column index in c#?
How can i get DataGridView row values and store in variables?


This will give you the gridview row index for the value:

String searchValue = "somestring";
int rowIndex = -1;
foreach(DataGridViewRow row in DataGridView1.Rows)
        rowIndex = row.Index;

Or a LINQ query

int rowIndex = -1;

DataGridViewRow row = dgv.Rows
     .Where(r => r.Cells["SystemId"].Value.ToString().Equals(searchValue))

rowIndex = row.Index;

then you can do:

dataGridView1.Rows[rowIndex].Selected = true;