I have a TextBox
named txtvalue
.
Then I have a DataGridView
with a column named Id
.
My problem is how to set the row of the DataGridView
selected by value of txtvalue
equal with column ID
.
The text in textbox is not number, i just want it equal to column "ID" in DataGridView
.
I know this way to set that but it so long, is there any fast way to get shorter not use Linq?
Foreach (DataGridViewRow row in dataGridView1.Rows)
{
if (row.Columns["Id"].Value.ToString().Equals(txtvalue.Text))
{
row.Selected = true;
break;
}
}
I want to have fast way without use loop? Any idea please?
The value of Columns "ID" of Datagridview is:
----- ID -----
abc
xyz
klm
mnz
bla...bla
So the value is not the number. and the textbox value is equal with that