search items in datagridview
-
hi. I have search Textbox13 which i enter a codeNumber display it on dataGridView1. every time a new line should display after i search. i need to add new row which also searched and so on. pls help. private void searchx() { string connectionString = ConfigurationManager.ConnectionStrings["smemo.Properties.Settings.smConnectionString"].ConnectionString.ToString(); con = new SqlConnection(connectionString); string Query = "Select CodeNo,Description,Qty,P_Local,Amount from Price_list where CodeNo= " + textBox13.Text; SqlCommand cmd = new SqlCommand(Query, con); SqlDataAdapter da = new SqlDataAdapter(); da.SelectCommand = cmd; //DataTable dat = new DataTable(); DataSet ds = new DataSet(); da.Fill(ds,"Price_list"); // BindingSource bs = new BindingSource(); //bs.DataSource = ds.Tables["Price_list"]; dataGridView1.DataSource = ds.Tables["Price_list"]; } thanks best regards zafa
so much of happy ending...
-
hi. I have search Textbox13 which i enter a codeNumber display it on dataGridView1. every time a new line should display after i search. i need to add new row which also searched and so on. pls help. private void searchx() { string connectionString = ConfigurationManager.ConnectionStrings["smemo.Properties.Settings.smConnectionString"].ConnectionString.ToString(); con = new SqlConnection(connectionString); string Query = "Select CodeNo,Description,Qty,P_Local,Amount from Price_list where CodeNo= " + textBox13.Text; SqlCommand cmd = new SqlCommand(Query, con); SqlDataAdapter da = new SqlDataAdapter(); da.SelectCommand = cmd; //DataTable dat = new DataTable(); DataSet ds = new DataSet(); da.Fill(ds,"Price_list"); // BindingSource bs = new BindingSource(); //bs.DataSource = ds.Tables["Price_list"]; dataGridView1.DataSource = ds.Tables["Price_list"]; } thanks best regards zafa
so much of happy ending...
-
hi. I have search Textbox13 which i enter a codeNumber display it on dataGridView1. every time a new line should display after i search. i need to add new row which also searched and so on. pls help. private void searchx() { string connectionString = ConfigurationManager.ConnectionStrings["smemo.Properties.Settings.smConnectionString"].ConnectionString.ToString(); con = new SqlConnection(connectionString); string Query = "Select CodeNo,Description,Qty,P_Local,Amount from Price_list where CodeNo= " + textBox13.Text; SqlCommand cmd = new SqlCommand(Query, con); SqlDataAdapter da = new SqlDataAdapter(); da.SelectCommand = cmd; //DataTable dat = new DataTable(); DataSet ds = new DataSet(); da.Fill(ds,"Price_list"); // BindingSource bs = new BindingSource(); //bs.DataSource = ds.Tables["Price_list"]; dataGridView1.DataSource = ds.Tables["Price_list"]; } thanks best regards zafa
so much of happy ending...
Though your message subject a bit different than what you want to achive ( you are actually not searching grid rather trying to display appened result :laugh: it seems ), here is how you can achive that 1. Create an empty DataTable with columns that you want to display in grid. 2. Get the seach result from DB and "append" new result set ( one or more row which comes as your search result) 3. Bind the "updated" DataTable object to grid. Let me know if you can do that. Let me know if I have misunderstood your mesasge.
Thanks, Arindam D Tewary
-
Maintain a custom collection and add the newly searched item in the list every time. Bind the data grid with the collection.
Regards, Prakash Kalakoti
-
Though your message subject a bit different than what you want to achive ( you are actually not searching grid rather trying to display appened result :laugh: it seems ), here is how you can achive that 1. Create an empty DataTable with columns that you want to display in grid. 2. Get the seach result from DB and "append" new result set ( one or more row which comes as your search result) 3. Bind the "updated" DataTable object to grid. Let me know if you can do that. Let me know if I have misunderstood your mesasge.
Thanks, Arindam D Tewary