Hi!
I am designing a form which contains a datagridview which can display all customer orders. I also have a button inside the datagridview so that if a user clicks the button it will open another form which contains the items which the customer ordered in a datagridview.
I am using the code below on the first form.
private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
{
Item i = new Item();
i.Show();
}
Item is the name of the second form.
The second form contains the following code in the form load event.
SqlConnection con = new SqlConnection(Properties.Settings.Default.Stock_ControlConnectionString);
try
{
con.Open();
}
catch (Exception)
{
MessageBox.Show("Error with the database Connection");
}
try
{
string query = "Select * From Order_Items_Table ";
SqlDataAdapter da = new SqlDataAdapter(query, con);
DataTable dt = new DataTable();
da.Fill(dt);
dataGridView1.DataSource = dt;
}
catch (Exception)
{
MessageBox.Show("Error Occured");
}
}
The code in the second form will display all the items on the Order Items Table. I want a c# code which can pass the orderID value which is the first cell value in the datagrid from the first form to the second form so that the item form will display the data according to the orderID
I hope someone can help me out in this.
Thanks in advance.
Mirfath