private void dgvPackages_Selected(object sender, EventArgs e) { dgvProductsSuppliers.Rows.Clear(); int index = dgvPackages.CurrentCell.RowIndex; //get the the user selection Package selectedPackage = packages[index]; //get the package details this.DisplayPackage(selectedPackage); //display package details List <Product> productList = PackageDB.GetProducts(selectedPackage.PackageID); List <Supplier> supplierList = PackageDB.GetSuppliers(selectedPackage.PackageID); //add rows to the dTgrid view for (int i = 0; i < productList.Count; i++) { dgvProductsSuppliers.Rows.Add(); } //add package data to the rows for (int i = 0; i <= productList.Count - 1; i++) { dgvProductsSuppliers.Rows[i].Cells[0].Value = productList[i].ProdName; dgvProductsSuppliers.Rows[i].Cells[1].Value = supplierList[i].SupName; } }