Quantcast
Channel: Windows Forms Data Controls and Databinding forum
Viewing all articles
Browse latest Browse all 2535

DataGridView Filter by Multiple Columns

$
0
0

Hello;

I've a datagridview with two columns name and surname.

I want to filter datagridview by textbox name or surname. (fulltextsearch)

((DataTable)dataGridView1.DataSource).DefaultView.RowFilter doesn't work because of bindingsource

dt.DefaultWiew.RowFilter works for dt but datagridview doesn't be filtered.

            DataSet ds = new DataSet();
            SqlConnection conn = new SqlConnection("Data Source=.\\SQLEXPRESS;Initial Catalog=DBEMPEROR;Integrated Security=SSPI;");
            conn.Open();
            SqlDataAdapter adp = new SqlDataAdapter();
            SqlCommand comm = new SqlCommand();
            comm.CommandText = "select name, surname from PERSON";
            comm.Connection = conn;
            adp.SelectCommand = comm;
            DataTable dt = new DataTable("person");
            adp.Fill(dt);
            ds.Tables.Add(dt);
            bindingSource1.DataSource = ds; //from toolbox
            bindingSource1.DataMember = "person";
            dataGridView1.DataSource = bindingSource1;


Viewing all articles
Browse latest Browse all 2535

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>