hi its me again,
i have this scenario where i need to search my datagridview using the textbox i have, i have tried copying other sites but what it gives me is errors, new columns and more errors,
my codes goes like this for loading my datas from the database to the gridview

private void cashier_update_Load(object sender, EventArgs e){   
con.ConnectionString = @"";
            con.Open();
            SqlDataAdapter sda = new SqlDataAdapter("SELECT entry_no,prod_id, prod_name, wantiti,item_status FROM Table_3 Where item_status= 'ACTIVE'", con); 
            DataTable dt = new DataTable();
            sda.Fill(dt);
            dataGridViewX1.Rows.Clear();
            foreach (DataRow item in dt.Rows)
            {
                int n = dataGridViewX1.Rows.Add();
                dataGridViewX1.Rows[n].Cells[0].Value = item[0].ToString();
                dataGridViewX1.Rows[n].Cells[1].Value = item[1].ToString();
                dataGridViewX1.Rows[n].Cells[2].Value = item[2].ToString();
                dataGridViewX1.Rows[n].Cells[3].Value = item[3].ToString();
               }
            con.Close();
        }   }

now what i need is to search the column 2 which is prod_name via key_up or textchange. thank you for the help .
more power

foreach (DataGridViewRow row in dataGridViewX1.Rows)
             {
                 if (row.Cells[1].Value.ToString().Equals(MyTextBoxText))
                 {
                     //do whatever
                 }
             }

Something like this perhaps?

Edited 2 Years Ago by ddanbe: typo

Comments
What I'd have done.
This question has already been answered. Start a new discussion instead.