I am working on a project where I need to display data from database to datagridview depending on combobox multiselection. Something like Data filter in MS Excell.
On checking or unckecking combobox item populate datagridview.
I was thinking to achieve this in this way?
SELECT * FROM articles WHERE name LIKE
Combobox is populating from database.
I am working in VS 2010, sqlCEserver, .net 3.5
Can someone have any idea how to do it?
Thank you.
Iftikar HussainPosted Aug 1, 2013, 2:32 AM
Regards,
Iftikar
Konstantin PankaricanPosted Aug 1, 2013, 2:26 AM
here's the code:
conn.Open();
SqlCommand sc = new SqlCommand("select naziv,cena from artikli", conn);
SqlDataReader reader; reader = sc.ExecuteReader();
DataTable dt = new DataTable();
dt.Columns.Add("naziv", typeof(string));
dt.Columns.Add("cena", typeof(string));
dt.Load(reader); comboBox1.ValueMember = "naziv"; comboBox1.DisplayMember = "cena"; comboBox1.DataSource = dt; conn.Close();
Iftikar HussainPosted Jul 31, 2013, 2:17 AM
Regards,
Iftikar
Konstantin PankaricanPosted Jul 31, 2013, 2:16 AM
Iftikar HussainPosted Jul 31, 2013, 12:51 AM
Is it the same post
http://www.c-sharpcorner.com/Forums/Thread/221920/filtering-database-data.aspx
Regards,
Iftikar