Hello all,
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 ,
form1:
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.
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:
form1:
private void button1_Click(object sender, EventArgs e)
{
try
{
if (textBox1.Text == "")
{
MessageBox.Show("Please Enter the Input Key.", "Error Message");
}
else
{
DataTable dataTable = new DataTable();
con = new SqlConnection(s);
con.Open();
cmd = new SqlCommand("select Destinations,TimeofDay,DialCode,EffectiveDate,NewOffer from RateSheets where Destinations='" + textBox1.Text + "'", con);
SqlDataReader sqlDataReader = cmd.ExecuteReader();
dataTable.Load(sqlDataReader);
con.Close();
form2 fm = new testing();
fm.Show();
dataGridView1.DataSource = dataTable;
}
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
}
}
Thanks in advance...