@LeaV, Welcome to Microsoft Q&A, based on my test, I reproduced your problem. If we used the number as the column name, we need to add []
for that column in the RowFilter string.
Here is a code example you could refer to.
private void button1_Click(object sender, EventArgs e)
{
string text = textBox1.Text;
string colName = dataGridView1.Columns[1].Name;//Column Number of Search
((DataTable)dataGridView1.DataSource).DefaultView.RowFilter = string.Format(colName + " = '{0}'", text.Trim().Replace("'", "''"));
}
Tested Result:
If the answer is the right solution, please click "Accept Answer" and upvote it.If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.