public partial class Form1 : Form { public ProductsBL productBL; public ArrayList prodList; ArrayList list; public Form1() { InitializeComponent(); productBL = new ProductsBL(); prodList = new ArrayList(); prodList = productBL.getProducts(); dataGridView1.DataSource = prodList; dataGridView1.Columns[0].Visible = false; prodList = productBL.loadComboboxProductID(); comboBox1.DataSource = prodList; //prodList = new ArrayList(); } } private void comboBox1_SelectedIndexChanged(object sender, EventArgs e) { Products products = productBL.getSpecificProducts(Convert.ToInt32 (comboBox1.SelectedValue)); dataGridView1.DataSource = products; } Below is my Business Layer public Products getSpecificProducts(int productID) { using (SqlConnection con = new SqlConnection(ConnectionString)) { SqlCommand cmd = new SqlCommand("procGetSingleRowOnProducts", con); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add(new SqlParameter("@productID", SqlDbType.Int)); cmd.Parameters["@productID"].Value = productID; con.Open(); SqlDataReader reader = cmd.ExecuteReader(); reader.Read(); Products products = new Products(Convert.ToInt32(reader["ProductID"]), Convert.ToString(reader["productName"]), Convert.ToInt32(reader["supplierID"]), Convert.ToInt32(reader["categoryID"]), Convert.ToString(reader["quantityPerUnit"]), Convert.ToDouble(reader["unitPrice"]), Convert.ToInt16(reader["UnitsInStock"]), Convert.ToInt16(reader["UnitsOnOrder"]), Convert.ToInt16(reader["ReorderLevel"]), Convert.ToBoolean(reader["Discontinued"])); return products; }//End }
Products products = productBL.getSpecificProducts(Convert.ToInt32(comboBox1.SelectedItem));
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)