Quantcast
Channel: CSharp Forum Latest Questions
Viewing all articles
Browse latest Browse all 32088

filter datagrid by different criteria

$
0
0
Hi :)

I want to filter my datagridview by different criteria..I have a form with 5 checkboxes, if the first checkbox is checked then appears a textbox where you have to introduce the name, if the second checkbox is checked then appears a combobox where you have to choose an option for client_type..and so on..I don't know how to filter if for example 3 checkboxes are checked or if all the checkboxes are checked..Here's my code. 

 System.Data.SqlClient.SqlConnection conn = new System.Data.SqlClient.SqlConnection();
            conn.ConnectionString = ..";
            conn.Open();

 DataSet dataSet=new DataSet();
            BindingSource clientBS = new BindingSource();

            System.Data.SqlClient.SqlDataAdapter dataAdapter1 = new System.Data.SqlClient.SqlDataAdapter("SELECT * FROM client", conn);
            dataAdapter1.Fill(dataSet, "client");
            clientBS.DataSource = dataSet.Tables["client"];
            dgv.DataSource = clientBS;


            if (checkBox1.Checked == true)
            {
                dgv.DataSource = dataSet.Tables["client"].DefaultView;
                dataSet.Tables["client"].DefaultView.RowFilter = "denumire LIKE '%" + textBox1.Text + "%'";
            } 

Viewing all articles
Browse latest Browse all 32088

Trending Articles