I really want to know how can I pass a whole datagridview values to another datagridview in another form? using c# windows application.
i have two form ,
i have one search option which is have,
one text box and one search button,
when i type something related to the table field in my text box and click search button,
the corresponding data has displayed to another form datagridview, that means form2.
i have only datagridview.
please my code see below where i did mistake my code and let me know the solution please..
my code is:
private void button1_Click(object sender, EventArgs e)
if (textBox1.Text == "")
MessageBox.Show("Please Enter the Input Key.", "Error Message");
DataTable dataTable = new DataTable();
con = new SqlConnection(s);
cmd = new SqlCommand("select Destinations,TimeofDay,DialCode,EffectiveDate,NewOffer from RateSheets where Destinations='" + textBox1.Text + "'", con);
SqlDataReader sqlDataReader = cmd.ExecuteReader();
form2 fm = new testing();
dataGridView1.DataSource = dataTable;
catch (Exception ex)
Thanks in advance...