I have created a simple DataGridView
through the toolbox and have selected data through the wizard (no code in .cs file) from a 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 enters a "contact person name" such as "Altaf" and then clicks on search, the GridView
should refresh and only entries with ticketid=4
should appear.
The only code in the .cs file (which is auto-generated) is:
private void Form2_Load(object sender, EventArgs e)
{
this.tblTicketDetailTableAdapter.Fill(this.sTDataSet1.tblTicketDetail); //auto-generated
}
I tried this in a ButtonClick
event as suggested by someone but it generates the 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 WinForms coding, so please explain in detail.