private void comboBoxSelectProduct_SelectedIndexChanged(object sender, EventArgs e) { DataTable dt = new DataTable(); dt = retrieve.GetId("usp_GetProductID", comboBoxSelectProduct.Text); textBoxQuantity.Clear(); textBoxTotalCost.Clear(); textBoxProdCost.Clear(); textBoxUnit.Clear(); if (dt.Rows.Count > 0) { ProductId = Convert.ToInt32(dt.Rows[0][0].ToString()); DataTable dtPrice = new DataTable(); dtPrice = retrieve.GetProductPriceUnitStock(ProductId); if (dtPrice.Rows.Count > 0) { textBoxProdCost.Text = dtPrice.Rows[0][3].ToString(); textBoxUnit.Text = dtPrice.Rows[0][1].ToString(); textBoxAvailableStock.Text = dtPrice.Rows[0][2].ToString(); AvailableStock = Convert.ToDecimal(dtPrice.Rows[0][2].ToString()); } } foreach (DataGridViewRow row in dataGridViewSalesLines.Rows) { if (Convert.ToInt32(row.Cells["ProductIdGv"].Value) == ProductId) { textBoxQuantity.Text = (row.Cells["ProductQuantityGv"].Value).ToString(); textBoxTotalCost.Text = (row.Cells["ProductTotalPrice"].Value).ToString(); break; } } }