Guys I have created a simple datagridview through toolbox and selected data through wizard (no code in .cs file) from database. It is working flawlessly as you can see in the picture below.
Now I want to filter the entries in it by contact person name. I have a textbox and search button so when the user enter a "contact person name" such as "Altaf" and then click on search, the gridview should refresh and only entry with ticketid=4 should appear.
The only code in the .cs file is : (it was auto-generated)
private void Form2_Load(object sender, EventArgs e)
{
this.tblTicketDetailTableAdapter.Fill(this.sTDataSet1.tblTicketDetail); //auto-generated
}
I tried this in buttonClick event as suggested by someone but it generates error : "Cannot interpret token '{' at position 27"
BindingSource bs = new BindingSource();
bs.DataSource = dataGridView1.DataSource;
bs.Filter = issuerNameDataGridViewTextBoxColumn + "like '%" + txtbxSearch.Text.Trim().Replace("'", "''") + "%'";
dataGridView1.DataSource = bs.DataSource;
I have no experience in datagridviews or win form coding for that matter, so please explain in detail. Your help is really appreciated.
Regards.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…